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

求查错。。

Posted by zengmuhan at 2011-03-12 11:48:04 on Problem 2528
#include<iostream>
using namespace std;

int cases;
int n;
int a[10000005] = {0};
bool used[10005];
int s,e;

int main()
{
	int i,j;
	cin>>cases;
	while(cases--)
	{
		memset(used,0,sizeof(used));
		memset(a,0,sizeof(a));
		int ans = 0;
		cin>>n;
		for(i = 1;i <= n;++i)
		{
			scanf("%d%d",&s,&e);
			for(j = s;j <= e;++j)
				a[j] = i;
		}
		for(i = 1;i <= 10000005;++i)
		{
			if(a[i] == 0)continue;
			if(used[a[i]] == 0)
			{
				ans ++;
				used[a[i]] = 1;
			}
		}
		printf("%d\n",ans);
	}//end of while
	return 0;
}

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