UVA 10258 Contest Scoreboard

                                                 Contest Scoreboard

                                                                                                                    Time limit: 3.000 seconds

Think the contest score boards are wrong? Here's your chance to come up with the right rankings.

Contestants are ranked first by the number of problems solved (the more the better), then by decreasing amounts of penalty time. If two or more contestants are tied in both problems solved and penalty time, they are displayed in order of increasing team numbers.

A problem is considered solved by a contestant if any of the submissions for that problem was judged correct. Penalty time is computed as the number of minutes it took for the first correct submission for a problem to be received plus 20 minutes for each incorrect submission received prior to the correct solution. Unsolved problems incur no time penalties.

Input:

The input begins with a single positive integer on a line by itself indicating the number of the cases following, each of them as described below. This line is followed by a blank line, and there is also a blank line between two consecutive inputs.

Input consists of a snapshot of the judging queue, containing entries from some or all of contestants 1 through 100 solving problems 1 through 9. Each line of input will consist of three numbers and a letter in the format

contestant problem time L

where L can be C, I, R,U orE. These stand for Correct, Incorrect, clarification Request, Unjudged and Erroneous submission. The last three cases do not affect scoring.

Lines of input are in the order in which submissions were received.

Output:

For each test case, the output must follow the description below. The outputs of two consecutive cases will be separated by a blank line.

Output will consist of a scoreboard sorted as previously described. Each line of output will contain a contestant number, the number of problems solved by the contestant and the time penalty accumulated by the contestant. Since not all of contestants 1-100 are actually participating, display only the contestants that have made a submission.

Sample Input:

1

1 2 10 I
3 1 11 C
1 2 19 R
1 2 21 C
1 1 25 C

Sample Output:

1 2 66
3 1 11

题目链接:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=14&page=show_problem&problem=1199

WA了一天,也没有找出错误。后来才知道是输入的时候没处理好,getchar()把不该吸收的回车吸收了。

#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;

struct contestant {
	int id; //队伍好
	int penalty; //罚时
	int cnt[10]; //每道题错误的次数
	int solved[10]; //每道题的解决状态
	int submit; //是否有提交记录
	int problem; //AC的题目总数
}a[105];

bool comp(contestant a1, contestant a2) {
	if(a1.problem != a2.problem)
		return a1.problem > a2.problem;
	if(a1.penalty != a2.penalty)
		return a1.penalty < a2.penalty;
	return a1.id < a2.id;
}

void Init() {
	for(int i = 0; i < 105; i++) {
		a[i].id = i;
		a[i].penalty = a[i].problem = a[i].submit = 0;
		memset(a[i].solved, 0, sizeof(a[i].solved));
		memset(a[i].cnt, 0, sizeof(a[i].cnt));
	}
}

int main()
{
	int T, i, contest, time, pro, cas;
	char ch, str[100];
	scanf("%d",&T);
	getchar();
	int tmp = T;
	for(cas = 1; cas <= T; cas++) {
		if(cas == 1) //这里没处理好,WA了一天
			getchar();
		Init();
		while(gets(str) != NULL && strcmp(str, "")) {
			contest = pro = time = 0;
			int len = strlen(str), s = 0;
			for(i = 0; i < len - 1; i++) {
				if(str[i] >= '0' && str[i] <= '9')
					s = s * 10 + str[i] - '0';
				else {
					if(!contest) contest = s;
					else if(contest && !pro) pro = s;
					else if(contest && pro) time = s;
					s = 0;
				}
			}
			ch = str[len - 1];
			a[contest].submit = 1;
			if(ch == 'C' && !a[contest].solved[pro]) {
				a[contest].problem++;
				a[contest].penalty += (time + a[contest].cnt[pro] * 20);
				a[contest].solved[pro] = 1;
			}
			else if(ch == 'I' && !a[contest].solved[pro]) {
				a[contest].cnt[pro]++;
			}
		}
		sort(a, a+105, comp);
		if(cas > 1) printf("\n");
		for(i = 0; i < 105; i++)
			if(a[i].submit)
				printf("%d %d %d\n", a[i].id, a[i].problem, a[i].penalty);
	}
	return 0;
}



阅读更多

Contest Scoreboard

09-09

Think the contest score boards are wrong? Here's your chance to come up with the right rankings.nContestants are ranked first by the number of problems solved (the more the better), then by decreasing amounts of penalty time. If two or more contestants are tied in both problems solved and penalty time, they are displayed in order of increasing team numbers.nnA problem is considered solved by a contestant if any of the submissions for that problem was judged correct. Penalty time is computed as the number of minutes it took for the first correct submission for a problem to be received plus 20 minutes for each incorrect submission received prior to the correct solution. Unsolved problems incur no time penalties.nnnInputnnInput consists of a snapshot of the judging queue, containing entries from some or all of contestants 1 through 100 solving problems 1 through 9. Each line of input will consist of three numbers and a letter in the formatnncontestant problem time Lnnwhere L can be C, I, R, U or E. These stand for Correct, Incorrect, clarification Request, Unjudged and Erroneous submission. The last three cases do not affect scoring.nnLines of input are in the order in which submissions were received.nnSubsequent test cases are separated with a single blank line.nnnOutputnnOutput will consist of a scoreboard sorted as previously described. Each line of output will contain a contestant number, the number of problems solved by the contestant and the time penalty accumulated by the contestant. Since not all of contestants 1-100 are actually participating, display only the contestants that have made a submission.nnSeparate output for different cases with a single blank line.nnnSample Inputnn1 2 10 In3 1 11 Cn1 2 19 Rn1 2 21 Cn1 1 25 CnnnSample Outputnn1 2 66n3 1 11n

换一批

ICPC Scoreboard

06-01

Problem DescriptionnCharles is the contest director for the ICPC Tumbolian regional contest. His responsibility is ensuring the contest flows smoothly, that the contest rules are applied fairly, and, of course, announcing the final contest ranking.nnAccording to ICPC rules, a team with more solved problems ranks above a team with less solved problems. If two teams have the same number of solved problems, the team with the smaller total penalty ranks above the team with the larger total penalty (in case both teams have the same number of solved problems and the same penalty, Charles considers them as tied).nnThe total penalty for a team is the sum of all the problem penalties of the problems that team has solved. The problem penalty for a problem is TP +EP ×FA, where TP is the time penalty for that problem, EP is the contest’s error penalty and FA is the number of failed attempts at solving the problem before submitting a correct solution.nnThe time penalty for a problem is the time since the start of the contest, in minutes, that the team needed to solve the problem. The error penalty is a positive integer chosen by the contest director, designed to reward teams that submit correct solutions on the first attempt.nnCharles wants to change the error penalty from the “standard” value of 20 minutes to stir things up. To study the effects of that change on the final rankings, he wants to know the range of error penalties that don’t change the final standings.nnIn other words, if team A is ahead of team B in the original standings, then A should be ahead of B in the modified standings; if A and B are tied in the original standings, they should also be tied in the modified standings (the original standings are the ones obtained with an error penalty of 20 minutes).nnCharles has been very busy organizing the Tumbolian regional, so he asked you to make a program that will compute the range for him.n nnInputnThe input contains several test cases. The first line of each test case contains two integers T and P separated by a single space, indicating the number of teams and the number of problems, respectively (2 <= T <= 100, 1 <= P <= 10). Each one of the next T lines describes the performance of a team. A team’s performance description is a line containing P problem descriptions separated by single spaces. Teams are not necessarily given in order of their final standings.nnEach problem description is a string “A/S”, where A is an integer representing the number of attempts that the corresponding team made at solving that problem (0 <= A <= 100), and S is either “-”, if the team did not solve that problem, or an integer indicating the number of minutes it took for the team to submit a correct solution (1 <= S <= 300). Attempts made after the first correct submission are not counted.nThe end of input is indicated by T = P = 0.n nnOutputnFor each test case in the input print two positive integers separated by a single space, indicating the smallest and largest error penalties that would not change the final ranking. If there is no upper bound for the error penalty, print a “*” instead of the upper bound.n nnSample Inputn5 3n0/- 0/- 0/-n2/- 2/- 1/-n1/60 1/165 1/-n1/80 0/- 2/120n0/- 1/17 0/-n4 2n17/- 5/-n2/7 3/-n3/- 2/-n1/15 0/-n3 2n1/- 2/15n2/53 1/17n1/70 1/20n0 0n nnSample Outputn1 24n9 *n20 20n

Rotating Scoreboard

10-05

DescriptionnnThis year, ACM/ICPC World finals will be held in a hall in form of a simple polygon. The coaches and spectators are seated along the edges of the polygon. We want to place a rotating scoreboard somewhere in the hall such that a spectator sitting anywhere on the boundary of the hall can view the scoreboard (i.e., his line of sight is not blocked by a wall). Note that if the line of sight of a spectator is tangent to the polygon boundary (either in a vertex or in an edge), he can still view the scoreboard. You may view spectator's seats as points along the boundary of the simple polygon, and consider the scoreboard as a point as well. Your program is given the corners of the hall (the vertices of the polygon), and must check if there is a location for the scoreboard (a point inside the polygon) such that the scoreboard can be viewed from any point on the edges of the polygon.nnInputnnThe first number in the input line, T is the number of test cases. Each test case is specified on a single line of input in the form n x1 y1 x2 y2 ... xn yn where n (3 ≤ n ≤ 100) is the number of vertices in the polygon, and the pair of integers xi yi sequence specify the vertices of the polygon sorted in order.nnOutputnnThe output contains T lines, each corresponding to an input test case in that order. The output line contains either YES or NO depending on whether the scoreboard can be placed inside the hall conforming to the problem conditions.nnSample Inputnn2n4 0 0 0 1 1 1 1 0n8 0 0 0 2 1 2 1 1 2 1 2 2 3 2 3 0nSample OutputnnYESnNO

没有更多推荐了,返回首页