ICPC 7014 Ideal Scoreboard

Professor Boffin is a regional contest director of ACM ICPC. He loves watching and analyzing the scoreboard during the contest. He believes that the scoreboard is ideal when all these criteria hold together: • Each team has solved at least one problem. • No team has solved all the problems. • Each problem is solved by at least one team. • No problem is solved by all the teams.
Obviously, the scoreboard is not ideal at the beginning of the contest, but it may become ideal during the contest. The scoreboard may remain ideal through the end of the contest, or it may lose this property some time later during the contest. In the latter case, it can be shown that it will never become ideal any more. Given the list of the submissions in a regional contest, you must determine the interval in which the scoreboard was ideal.
Input
The input consists of several test cases. Each test case starts with a line containing 3 space- separated integers T, P, and S which represent the number of teams, problems, and submissions respectively (1 ≤ T ≤ 150, 1 ≤ P ≤ 15, 0 ≤ S ≤ 5000). Each of the next S lines represents a contest submission with 4 space-separated parameters
• teamID: the identifier of the team, an integer in the range [1..T]. • problemID: the identifier of the problem, an uppercase letter from the first P letters of English alphabet. • submission−time: the time of submission, in ‘HH:MM:SS’ format, all 3 parts are exactly 2 digits (00 ≤ HH ≤ 05, 00 ≤ MM,SS ≤ 59). • result: the result of the submission. It can be one of the following sentences:
– Yes: Only this case shows that the corresponding team has successfully solved the problem. – No - Compilation Error: Unsuccessful submission due to a compilation error in the submitted program. – No - Wrong Answer: Unsuccessful submission since the submitted program had a wrong output. – No - Run-time Error: Unsuccessful submission due to a run-time error during the execution of the submitted program. – No - Time Limit Exceeded: Unsuccessful submission since the execution of the submitted program did not finish in the time limit. – No - Presentation Error: Unsuccessful submission due to a formatting error in the output of the submitted program.
No two submissions have the same time. The input terminates with a line containing ‘0 0 0’ which should not be processed as a test case.
Output
For each test case, output a line containing the ideal-interval of the corresponding contest. The interval must be provided with two times in exact ‘HH:MM:SS’ format (as described in the input). The first time shows the moment the scoreboard becomes ideal, and the second time shows the moment the scoreboard is not ideal anymore. If the scoreboard remains ideal through the end of the contest, the second time must be ‘--:--:--’. If the scoreboard never becomes ideal throughout the contest, both times must be ‘--:--:--’.
Sample Input
2 3 5 1 A 00:10:05 Yes 2 A 00:15:15 No - Wrong Answer 1 C 01:01:01 Yes 2 B 02:20:00 Yes 1 B 03:10:00 Yes 2 3 5 1 A 00:10:05 Yes 2 A 00:15:15 No - Wrong Answer 1 C 01:01:01 Yes 2 B 02:20:00 Yes 1 B 03:10:00 No - Wrong Answer 2 3 5 1 A 00:10:05 Yes 1 C 01:01:01 Yes 2 A 00:15:15 No - Wrong Answer 1 B 03:10:00 Yes 2 B 04:20:00 Yes 0 0 0
Sample Output

02:20:00 03:10:00 02:20:00 --:--:---:--:-- --:--:-


题意:给定一场比赛的情况。满足以下四个条件的时间为ideal时间。

• Each team has solved at least one problem. • No team has solved all the problems. • Each problem is solved by at least one team. • No problem is solved by all the teams.

求一场比赛的时候,满足IDEA的时间段。

#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>

#define N 150005
#define M 305
int table[200][20];
using namespace std;
int t,p,s;
int flag11,flag12,flag13,flag21,flag22,flag23;
typedef struct ed
{
	int num_team,num_p,t1,t2,t3,time;
}ed;
ed ans[6000];
int solve()
{
	//
	int cnt;
	for(int i = 1;i<=t;i++)
	{
		cnt = 0;
		for(int j = 0;j < p;j++)
		{
			if(table[i][j]!=-1)
				cnt++;
		}
		//cout<<cnt<<endl;
		if(cnt>0&&cnt<p)continue;
		else
			return 0;
	}
	
	for(int i = 0;i<p;i++)
	{
		cnt = 0;
		for(int j = 1;j <= t;j++)
		{
			if(table[j][i]!=-1)
			cnt++;	
		}
		//cout<<cnt<<endl;
		if(cnt>0&&cnt<t)continue;
		else
			return 0;
	}
	return 1;
}
bool cmmp(ed a,ed b)
{
	return a.time<b.time;
}
int main()
{
	while(scanf("%d%d%d",&t,&p,&s)==3)
	{
		if(t==0&&p==0&&s==0)break;
		memset(table,-1,sizeof(table));
		memset(ans,-1,sizeof(ans));
		flag11 = -1;
		flag21 = -1;
		int tt = 0;
		for(int i = 0;i<s;i++)
		{
			int num_team,num_p,num_time,t1,t2,t3;
			char num_pro;
			string ss;
			scanf("%d %c %d:%d:%d ",&num_team,&num_pro,&t1,&t2,&t3);
			cin >> ss;
			if(ss=="Yes")
			{
				num_p = num_pro-'A';
				num_time = ((t1*60)+t2)*60+t3;
				ans[tt].num_team = num_team;
				ans[tt].num_p = num_p;
				ans[tt].t1 = t1;
				ans[tt].t2 = t2;
				ans[tt].t3 = t3;
				ans[tt].time = num_time;
				tt++;
			}
			else
			{
				cin>>ss;
				cin >>ss;
				if(ss=="Time")
					cin >> ss;
				cin>>ss;
			}
		}
		sort(ans,ans+tt,cmmp);
		for(int i = 0;i<tt;i++)
		{
			table[ans[i].num_team][ans[i].num_p] = ans[i].time;
			int k;
				k = solve();
				//cout<<"///"<<k<<endl;
				if(k&&flag11==-1)
				{
		
						flag11 = ans[i].t1;
						flag12 = ans[i].t2;
						flag13 = ans[i].t3;
	
					
				}
				if(k==0&&flag11!=-1&&flag21==-1)//这里还有一个条件FLLAG21==-1忘了加,所以一直WA
					{
						flag21 = ans[i].t1;
						flag22 = ans[i].t2;
						flag23 = ans[i].t3;
					}
					
		}
				
		if(flag11==-1)
		cout<<"--:--:-- ";
		else
			printf("%02d:%02d:%02d ",flag11,flag12,flag13);
			//cout<<flag11<<":"<<	flag12<<":"<<flag13<<" ";
			
		if(flag21==-1)
		cout<<"--:--:--\n";
		else
		printf("%02d:%02d:%02d\n",flag21,flag22,flag23);
		//	cout<<flag21<<":"<<	flag22<<":"<<flag23<<endl;
	}
	
	return 0;
} 


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值