Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

题目和程序都看了N遍,我实在是找不出有什么错

Posted by zyz at 2007-04-16 21:56:45 on Problem 1089
谁能教教我?

#include<iostream>
using namespace std;

int main(){
    unsigned int number;
    while(cin>>number){
    
    char time[1000020];   //用于放间隔,如1 3存为time[1]不变,time[2]=time[3]=1;
    char pop[1000020];   //用于存放点
    memset(time, 0, 1000020*sizeof(char));
    memset(pop, 0, 1000020*sizeof(char));
    
    unsigned int top=0;
    while(number-->0){
        unsigned int left,right;
        cin>>left>>right;
        if(right>top)
            top=right;
        if(left==right){
            pop[left]++;
            continue;
        }
        left++;
        while(left<=right){
            time[left]++;
            left++;
        }
    }
    
    int in=0;
    for(number=0;number<=top+1;number++){
        if(time[number]){
            if(in==0){
                in=1;
                cout<<number-1<<" ";
            }
        }
        else{
            if(in){
                in=0;
                cout<<number-1<<endl;
            }
            if(pop[number] && !time[number+1]){
                cout<<number<<" "<<number<<endl;
            }
        }
    }
    }
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator