Page 1 of 6
10258 Multiple input issues
Posted: Wed Apr 17, 2002 1:45 pm
by Lawrence
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.

Posted: Wed Apr 17, 2002 6:31 pm
by Adrian Kuegel
Try to read the message type as %s, not %c, because it could be that it is not only one space between the last number and the character.
And a team participates even if it sends only clarification requests.
Posted: Wed Apr 17, 2002 8:17 pm
by Juergen Werner
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."
Posted: Fri Apr 19, 2002 11:33 am
by Lawrence
Adrian: tried on my machine with multiple spaces, my program handles them correctly. So the problem must be hiding somewhere else.
Posted: Mon Apr 22, 2002 12:57 am
by C8H10N4O2
Here is the pseudo code for my input routine:
1. Read N.
2. Loop from 1 to N: while fgets is not null, check if length is 0 or 1 (if so, terminate input set), sscanf the buffer char array
3. Process each input data set.
Posted: Wed Jul 02, 2003 7:01 am
by Sebasti
The problem with the input of this problem is in the end of each input. If there are spaces after the letter on the last line of each input and you read a char to skip to the next line, you will read a space, not a '\n'.
Then, to read the character like a string avoid this error.
Bye
10258 - Contest Scoreboard
Posted: Tue Jul 15, 2003 4:05 pm
by j0rdi
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
Posted: Wed Jul 16, 2003 8:05 am
by Dominik Michniewski
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
Posted: Wed Jul 16, 2003 2:55 pm
by anupam
try all the permutation for a problem.
as dominik said,(a great helper)
I got wa about the problem when not checking the first cond given by dominik.
Posted: Sat Jul 19, 2003 9:09 am
by carneiro
What should happen in those cases domnik ?
my program does :
1) add 20 miin penalty
2) nothing.
Should it be nothing / nothing ?
Posted: Sun Jul 20, 2003 10:11 am
by the LA-Z-BOy
anupam wrote:try all the permutation for a problem.
what does that mean anupam vai?
to
carneiro:
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.
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.
`before' is meant to be `early submission' to the judge...
Lines of input are in the order in which submissions were received.
so for the input
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
Posted: Mon Jul 21, 2003 12:01 pm
by carneiro
Alright

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
And the correct answer :
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
Posted: Wed Aug 13, 2003 9:07 am
by anupam
i mean a problem get ac after 2 wa. a problem get wa after 2 ac. a problem get ac same time wa.
a problem get ac after clar
a problem get wa after clar. etc.
thank you.
Posted: Wed Aug 13, 2003 9:09 am
by anupam
And a team participates even if it sends only clarification requests
adrian, i haven't noticed such a aline in the problem statement.
is there any?
if it is then, i should put answer such as
--
3 0 0
--
is it true for the other two cases?

Posted: Wed Aug 13, 2003 9:10 am
by anupam
And a team participates even if it sends only clarification requests
adrian, i haven't noticed such a aline in the problem statement.
is there any?
if it is then, i should put answer such as
--
3 0 0
--
is it true for the other two cases?
