10258 - Contest Scoreboard
Moderator: Board moderators
10258 Multiple input issues
Is this code enough to handle the multiple input in 10258?
[cpp]void main()
{
#ifdef ONLINE_JUDGE
FILE *fp=stdin;
#else
FILE *fp=fopen("b.in","r");
#endif
int n,p,t;
int i;
char l;
int j;
char buf[100];
fgets(buf,100,fp);
sscanf(buf,"%d",&j);
fgets(buf,100,fp);
while(j>0)
{
//......initializations
while(1)
{
if(!fgets(buf,100,fp))
break;
if(buf[0]=='\n')
break;
sscanf(buf,"%d %d %d %c",&n,&p,&t,&l);
//.....real things
}
printf("\n");
j--;
}
}[/cpp]
I've already got four wrong answers for this.
[cpp]void main()
{
#ifdef ONLINE_JUDGE
FILE *fp=stdin;
#else
FILE *fp=fopen("b.in","r");
#endif
int n,p,t;
int i;
char l;
int j;
char buf[100];
fgets(buf,100,fp);
sscanf(buf,"%d",&j);
fgets(buf,100,fp);
while(j>0)
{
//......initializations
while(1)
{
if(!fgets(buf,100,fp))
break;
if(buf[0]=='\n')
break;
sscanf(buf,"%d %d %d %c",&n,&p,&t,&l);
//.....real things
}
printf("\n");
j--;
}
}[/cpp]
I've already got four wrong answers for this.
-
- Guru
- Posts: 724
- Joined: Wed Dec 19, 2001 2:00 am
- Location: Germany
-
- New poster
- Posts: 27
- Joined: Wed Apr 17, 2002 7:54 pm
Well, no comment on the problem (sorry), but on the (s)scanf part of the last post:
sscanf(buf, "%d %d %d %c",&n,&p,&t,&l); does exactly what you want. There is no reason for using %s if there is only one character to read. The leading space before %c (" %c") eliminates any consecutive white spaces.
See Man-Pages (scanf, sscanf, ...):
1. "White space (such as blanks, tabs, or newlines) in the format string match any amount of white space, including none, in the input."
2. "c - Matches a sequence of width count characters (default 1); the next pointer must be a pointer to char, and there must be enough room for all the characters (no terminating NUL is added). The usual skip of leading white space is suppressed. To skip white space first, use an explicit space in the format."
sscanf(buf, "%d %d %d %c",&n,&p,&t,&l); does exactly what you want. There is no reason for using %s if there is only one character to read. The leading space before %c (" %c") eliminates any consecutive white spaces.
See Man-Pages (scanf, sscanf, ...):
1. "White space (such as blanks, tabs, or newlines) in the format string match any amount of white space, including none, in the input."
2. "c - Matches a sequence of width count characters (default 1); the next pointer must be a pointer to char, and there must be enough room for all the characters (no terminating NUL is added). The usual skip of leading white space is suppressed. To skip white space first, use an explicit space in the format."
10258 - Contest Scoreboard
I get always WA in problem 10258 (Contest Scoreboard). Is there any special case that i don't have consider? I think that my solution is correct but always the judge gives me WA.
Someone can give me a test case o explain me the problem (perhaps i don't know the form to calculte the time penalty)...
Please i need help......is urgent!!!!!!!
Thank you
Someone can give me a test case o explain me the problem (perhaps i don't know the form to calculte the time penalty)...
Please i need help......is urgent!!!!!!!
Thank you
-
- Guru
- Posts: 834
- Joined: Wed May 29, 2002 4:11 pm
- Location: Wroclaw, Poland
- Contact:
I think, that exists other thread to this problem ....
Be careful with:
- the same time when problem has WA and Acc
- time when WA is given after Acc
and so on ...
Besty regards
DM
Be careful with:
- the same time when problem has WA and Acc
- time when WA is given after Acc
and so on ...
Besty regards
DM
If you really want to get Accepted, try to think about possible, and after that - about impossible ... and you'll get, what you want ....
Born from ashes - restarting counter of problems (800+ solved problems)
Born from ashes - restarting counter of problems (800+ solved problems)
-
- Learning poster
- Posts: 94
- Joined: Wed Jul 31, 2002 12:44 pm
- Location: Dacca, Bangladesh
- Contact:
what does that mean anupam vai?anupam wrote:try all the permutation for a problem.
to carneiro:
so if the AC submission (C) is before any other submission (I, R, U, E), you can ignore the later submissions to count penalty stuffs.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.
`before' is meant to be `early submission' to the judge...
so for the inputLines of input are in the order in which submissions were received.
1 1 10 C
1 1 10 I
you should not count penalty... while
1 1 10 I
1 1 10 C
you should count penalty.
And make sure you are showing each contestant that has made any kind of submission.
thanks...
Istiaque Ahmed
Istiaque Ahmed [the LA-Z-BOy]
-
- Learning poster
- Posts: 54
- Joined: Sun May 18, 2003 1:19 am
- Location: Rio de Janeiro, Brazil
- Contact:
Alright
My problem was not sorting the ones who submitted but didn't score.
Here's a test case for you :
And the correct answer :
My problem was not sorting the ones who submitted but didn't score.
Here's a test case for you :
Code: Select all
1
38 1 0 C
48 1 1 R
83 1 2 E
89 9 3 R
7 5 4 R
68 1 5 U
61 1 6 U
27 1 7 R
21 7 8 R
55 2 9 I
54 1 10 U
69 1 11 C
59 2 12 I
43 3 13 I
7 9 14 R
84 6 15 R
52 8 16 C
32 7 17 C
87 7 18 U
44 1 19 I
87 6 20 I
21 6 21 U
6 4 22 E
44 8 23 I
72 5 24 R
35 1 25 E
57 4 26 E
24 5 27 C
30 3 28 I
85 9 29 I
72 5 30 U
30 7 31 U
8 5 32 R
88 1 33 I
61 2 34 C
35 6 35 R
77 4 36 C
46 8 37 I
21 9 38 E
74 3 39 R
7 4 40 U
25 4 41 R
48 1 42 I
87 1 43 C
84 3 44 U
96 9 45 U
60 5 46 R
75 2 47 I
29 4 48 E
3 7 49 I
Code: Select all
38 1 0
69 1 11
52 1 16
32 1 17
24 1 27
61 1 34
77 1 36
87 1 43
3 0 0
6 0 0
7 0 0
8 0 0
21 0 0
25 0 0
27 0 0
29 0 0
30 0 0
35 0 0
43 0 0
44 0 0
46 0 0
48 0 0
54 0 0
55 0 0
57 0 0
59 0 0
60 0 0
68 0 0
72 0 0
74 0 0
75 0 0
83 0 0
84 0 0
85 0 0
88 0 0
89 0 0
96 0 0
Last edited by carneiro on Sun Sep 14, 2003 12:52 am, edited 1 time in total.
[]s
Mauricio Oliveira Carneiro
Mauricio Oliveira Carneiro