10258 - Contest Scoreboard

All about problems in Volume 102. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

Lawrence
New poster
Posts: 17
Joined: Sat Feb 09, 2002 2:00 am
Location: China
Contact:

10258 Multiple input issues

Post 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. :(
Adrian Kuegel
Guru
Posts: 724
Joined: Wed Dec 19, 2001 2:00 am
Location: Germany

Post 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.
Juergen Werner
New poster
Posts: 27
Joined: Wed Apr 17, 2002 7:54 pm

Post 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."
Lawrence
New poster
Posts: 17
Joined: Sat Feb 09, 2002 2:00 am
Location: China
Contact:

Post by Lawrence »

Adrian: tried on my machine with multiple spaces, my program handles them correctly. So the problem must be hiding somewhere else.
C8H10N4O2
Experienced poster
Posts: 137
Joined: Wed Feb 27, 2002 2:00 am
Location: Pasadena, CA

Post 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.
Sebasti
New poster
Posts: 10
Joined: Sun Apr 13, 2003 11:41 pm
Contact:

Post 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
j0rdi
New poster
Posts: 6
Joined: Sun May 04, 2003 10:52 am

10258 - Contest Scoreboard

Post 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
Dominik Michniewski
Guru
Posts: 834
Joined: Wed May 29, 2002 4:11 pm
Location: Wroclaw, Poland
Contact:

Post 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
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)
anupam
A great helper
Posts: 405
Joined: Wed Aug 28, 2002 6:45 pm
Contact:

Post 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.
"Everything should be made simple, but not always simpler"
carneiro
Learning poster
Posts: 54
Joined: Sun May 18, 2003 1:19 am
Location: Rio de Janeiro, Brazil
Contact:

Post by carneiro »

What should happen in those cases domnik ?

my program does :

1) add 20 miin penalty
2) nothing.

Should it be nothing / nothing ?
[]s
Mauricio Oliveira Carneiro
the LA-Z-BOy
Learning poster
Posts: 94
Joined: Wed Jul 31, 2002 12:44 pm
Location: Dacca, Bangladesh
Contact:

Post 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
Istiaque Ahmed [the LA-Z-BOy]
carneiro
Learning poster
Posts: 54
Joined: Sun May 18, 2003 1:19 am
Location: Rio de Janeiro, Brazil
Contact:

Post 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
Last edited by carneiro on Sun Sep 14, 2003 12:52 am, edited 1 time in total.
[]s
Mauricio Oliveira Carneiro
anupam
A great helper
Posts: 405
Joined: Wed Aug 28, 2002 6:45 pm
Contact:

Post 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.
:oops: :oops:
"Everything should be made simple, but not always simpler"
anupam
A great helper
Posts: 405
Joined: Wed Aug 28, 2002 6:45 pm
Contact:

Post 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? :oops:
"Everything should be made simple, but not always simpler"
anupam
A great helper
Posts: 405
Joined: Wed Aug 28, 2002 6:45 pm
Contact:

Post 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? :oops:
"Everything should be made simple, but not always simpler"
Post Reply

Return to “Volume 102 (10200-10299)”