Page 2 of 4
Posted: Mon Jun 24, 2002 7:12 am
by Stefan Pochmann
mido: yes
10153EN: "left" as in "left out" and "right?" like in "am I right?"
Posted: Mon Jun 24, 2002 7:25 am
by 10153EN
Posted: Mon Jun 24, 2002 2:49 pm
by mido
left=remaining
right=correct
402 WA
Posted: Thu Jul 04, 2002 12:46 pm
by Revenger
Can anyone tell me why my program gets WA?
[pascal]Program p402;
Const MaxN = 100;
Var Inf,Card : Array[1..MaxN]of Integer;
N,X,i,j : Integer;
T,left,k : Integer;
begin
T:=0;
While Not Eof(InPut) Do begin
T:=T+1;
if T>1 then Writeln;
Writeln('Selection #',T);
Read(N,X);
for i:=1 to 20 do Read(Card);
left:=N;
for i:=1 to N do Inf:=0;
for i:=1 to 20 do begin
if left<=X then Break;
k:=0;
for j:=1 to N do begin
if Inf[j]=0 then begin
k:=k+1;
if k mod Card=0 then begin
Inf[j]:=1;
left:=left-1;
if left<=X then Break;
end;
end;
end;
end;
for i:=1 to N do
if Inf=0 then
Write(i,' ');
Writeln;
end;
end.[/pascal]
read previous mailing
Posted: Thu Jul 04, 2002 3:20 pm
by xenon
Why do you open a third thread on 402?
If you had read the previous threads, you could have found the answer.
One additional note:
you don't read line-breaks, so if there is a line-break after the last line in the inputfile, your program won't be able to detect the eof.
Another additional note:
The list of ``lucky" positions is then followed by a blank line.
Posted: Thu Jul 04, 2002 5:13 pm
by Revenger
Thank you!
And sorry for the third thread on 402

Larger X
Posted: Sat Jul 06, 2002 7:22 am
by manir

What is about larger X when we have finished our cards

Posted: Sat Jul 06, 2002 8:33 am
by 10153EN
As I remembered, there's a post in the past about problem 402 (It's created by me

) and it's taking about this. You can have a look at it~
WA Still
Posted: Sat Jul 06, 2002 11:22 am
by manir
My programs response:
I don't understand the problem. Can anyone help me?
Input:
10 2 3 5 4 3 2 9 6 10 10 6 2 7 3 4 7 4 5 3 2 4
47 6 11 2 7 3 4 8 5 10 7 8 3 7 4 2 3 9 10 2 5 3
31 9 5 8 2 1 7 7 11 3 6 5 4 9 10 5 2 1 5 3 9 7
16 3 11 2 7 3 4 8 5 10 7 8 3 7 4 2 3 9 10 2 5 3
25 1 7 7 7 7 8 8 8 8 9 9 9 9 10 10 10 10 11 11 11 11
10 11 3 5 4 3 2 9 6 10 10 6 2 7 3 4 7 4 5 3 2 4
3 2 3
10 11 3 5 4 3 2 9 6 10 10 6 2 7 3 4 7 4 5 3 2 4
Output:
Selection #1
1 8
Selection #2
1 3 16 23 31 47
Selection #3
6 8 12 14 17 21 23 26 28
Selection #4
1 3 16
Selection #5
1 2 3 4 5 6 11 19
Selection #6
1 2 3 4 5 6 7 8 9 10
Selection #7
1 2
Selection #8
1 2 3 4 5 6 7 8 9 10
Posted: Sat Jul 06, 2002 11:47 am
by 10153EN
The outputs for me is the same as yours, except the third last and the last case.
In these two cases, i think it should not appear in the judge's data, as the number of lucky people is <= the total number of participant, as stated in the input description.
What to do then
Posted: Sat Jul 06, 2002 12:38 pm
by manir
But if the Judge Input is ok my program should work.
[c]
/*@begin_of_source_code*/
/* @JUDGE_ID: 13965AB 402 C*/
#include<stdio.h>
int people[51], remain, total, stop;
void init(){
for(int x=0;x<50;x++)
people[x]=1;
remain=0;total=0;
stop=0;
}
void main(){
int n,x,cur,f, count,c=0, space=0, cont;
#ifndef ONLINE_JUDGE
freopen("c:\\tcwin\\bin\\402.in","rt",stdin);
freopen("c:\\tcwin\\bin\\402.out","wt",stdout);
#endif
while(scanf("%d%d",&n,&x)==2){
if(c>0) printf("\n\n");
init();
if(x>n || n<=0 || x==0){
c++;
printf("Selection #%d\n",c);
space=0;
for(f=0;f<n;f++){
if(space) printf(" ");
printf("%d",f+1);
space++;
}
}
else{
total=n; stop=x; remain=n;
cont=0;
while(remain>stop){
if(cont>=20) break;
scanf("%d",&cur);
cont++;
count=0;
for(f=0;f<total;f++){
if(people[f]) count++;
if (count==cur){
if(remain<=stop) break;
people[f]=0;
remain--;
count=0;
}
}
}
c++;
printf("Selection #%d\n",c);
space=0;
for(f=0;f<total;f++)
if(people[f]){
if(space>0)printf(" ");
printf("%d",f+1);
space++;
}
}
char *st;
scanf("%[^\n]%c",st);
}
}
/*@end_of_source_code*/
[/c]
Posted: Sat Jul 06, 2002 1:44 pm
by Picard
the problem is:
1. you pass an unassigned char* pointer for %[^\n]
2. you don't pass parameter for %c
Posted: Sat Jul 06, 2002 3:43 pm
by manir
Thanks.
But I still get a nice WA.
Posted: Sat Jul 06, 2002 4:28 pm
by Picard
how did you correct it? i replaced the mentioned two lines with 'while (getchar()!=10);' and it got PE (but not WA).
Posted: Sat Jul 06, 2002 5:06 pm
by manir
Thanks for your help.
This show no problem while I test in my computer. Probably the word processor I am using is making the problem.
I waste a whole day to solve this.
