Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
Re:题目和程序都看了N遍,我实在是找不出有什么错In Reply To:题目和程序都看了N遍,我实在是找不出有什么错 Posted by:zyz at 2007-04-16 21:56:45 终于发现是char类型溢出了. 虽然改正后TLE,但终于知道为什么WA了 > 谁能教教我? > > #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]++; --> pop[left]='1'; > continue; > } > left++; > while(left<=right){ > time[left]++; --> time[left]='1'; > 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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator