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

为什么这样用个memset函数就不行了呢?

Posted by jianzhi at 2011-10-05 16:05:28 on Problem 1083
#include<iostream>
using namespace std;
void test_1083()
{
	int T;
	cin>>T;
	int N;
	
	int max=-1;
	unsigned start,end;
	while(T--){
		cin>>N;
		int corridor[201]={0};
		for(int i=0;i!=N;++i){
			cin>>start>>end;
			if(start>end){
				int temp=end;
				end=start;
				start=temp;
			}
			for(int j=(start+1)/2;j!=(end+1)/2+1;++j){
				++corridor[j];
			}
		}
		for(int i=1;i!=201;++i){
			if(corridor[i]>max)
				max=corridor[i];
		}
		cout<<max*10<<endl;
		//memset(corridor,0,201);
		max=-1;
	}
}
int main()
{
	test_1083();
}
这样行但是为什么这样Wrong Answer呢?
#include<iostream>
using namespace std;
void test_1083()
{
	int T;
	cin>>T;
	int N;
	int corridor[201]={0};
	int max=-1;
	unsigned start,end;
	while(T--){
		cin>>N;
		for(int i=0;i!=N;++i){
			cin>>start>>end;
			if(start>end){
				int temp=end;
				end=start;
				start=temp;
			}
			for(int j=(start+1)/2;j!=(end+1)/2+1;++j){
				++corridor[j];
			}
		}
		for(int i=1;i!=201;++i){
			if(corridor[i]>max)
				max=corridor[i];
		}
		cout<<max*10<<endl;
		memset(corridor,0,201);
		max=-1;
	}
}
int main()
{
	test_1083();
}

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