Page 3 of 4
Posted: Mon Jul 15, 2002 12:21 pm
by Dominik Michniewski
In problem description says:
The next 20 integers are the values of the first 20 cards in the deck.
But that not true .... integers may be less ....
GIVE SOME TEST INPUT FOR 402
Posted: Wed Jul 24, 2002 3:50 pm
by NONAME_SUST
Hi,
I have a problem with 402. I have tried with example input and output an got the exact result. Can anyone give me some input and output..
Posted: Wed Jul 24, 2002 5:26 pm
by Dominik Michniewski
I (and maybe more persons) have a request for you:
try to read messages on this board before you start new thread .... examples, which you are looking for, are in one of threads below ....
nice reading

)
YOU ARE TOO SHORT
Posted: Mon Jul 29, 2002 8:44 am
by NONAME_SUST
Hi,
what y write on ur header r too short. So..try to make the header bigger as anyone can understand. Moreover..Thanks for ur wrong answer..So resubbmit ur problem with 20 minutes penalty...
i solved it, but can't get out of the presentation error
Posted: Tue Aug 20, 2002 2:48 am
by Shahid
hi, can nayone help me to out of theis presentaion error, i tried several times but all failed...her is my code :
[c]
/*@BEGIN_OF_SOURCE_CODE*/
#include<stdio.h>
void main()
{
int lot, luc, deck[20], man[51], i, j, p, rest, bad, count = 0;
while(1)
{
if(count)
printf("\n");
i = scanf("%d", &lot);
if(i != 1)
break;
scanf("%d", &luc);
j = 0;
rest = 0;
bad = lot - luc;
for(i = 0; i < 20; i++)
scanf("%d", &deck);
for(i = 0; i < lot; i++)
man = 1;
count++;
for(i = 0; i < 20; i++)
{
if(rest == bad)
break;
for(;;)
{
for(p = 0; p < deck; j++ )
if(man[j])
p++;
j--;
if(j > (lot - 1))
{
j = 0;
break;
}
else
{
man[j] = 0;
rest++;
if(rest == bad)
break;
}
}
}
printf("Selection #%d\n", count);
for(i = 0; i < lot; i++)
if(man)
printf("%d ", i+1);
}
}
/*@END_OF_SOURCE_CODE*/
[/c]
thanx in advance
Posted: Wed Aug 21, 2002 10:53 am
by Dominik Michniewski
imagine that & is space

I think that your solution output something like this
Selection
1&2&
I think, that after last digit should not be a space
try
printf("<first number>");
for(...) printf("<space><another number>);

i changed, but no change in judge reply....
Posted: Fri Aug 30, 2002 11:18 pm
by Shahid
hi , i changed as u said...but no way...judge says P.E. again.....whats the problem? here is the changed code:
[cpp] /*@BEGIN_OF_SOURCE_CODE*/
#include<stdio.h>
void main()
{
int lot, luc, deck[25], man[55], i, j, p, rest, bad, count = 0;
while(1)
{
i = scanf("%d", &lot);
if(i != 1)
break;
scanf("%d", &luc);
j = 0;
rest = 0;
bad = lot - luc;
for(i = 0; i < 20; i++)
scanf("%d", &deck);
for(i = 0; i < lot; i++)
man = 1;
if(count)
printf("\n");
count++;
for(i = 0; i < 20; i++)
{
if(rest == bad)
break;
for(;;)
{
for(p = 0; p < deck; j++ )
if(man[j])
p++;
j--;
if(j > (lot - 1))
{
j = 0;
break;
}
else
{
man[j] = 0;
rest++;
if(rest == bad)
break;
}
}
}
printf("Selection #%d\n", count);
for(i = 0; i < lot; i++)
if(man)
{
printf("%d", i+1);
break;
}
i++;
for(; i < lot; i++)
if(man)
printf(" %d", i+1);
printf("\n");
}
}
/*@END_OF_SOURCE_CODE*/
[/cpp]
Posted: Mon Dec 02, 2002 12:46 pm
by supermin
Adrian Kuegel wrote:Your output is correct, but test your program with this input (I am not sure that it is used, but I considered the case in my program):
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 2 3 4 5 6 7 8 9 10
I ignore this sample,but I still got Acceptd..
I thougth the judge dosen't have this case.
402 M*A*S*H wrong answer
Posted: Sun Dec 08, 2002 3:11 pm
by hank

Why I got WA?
here is my source.
help me! ^_^
[c]
/* @JUDGE_ID:17511FE 402 C */
/* A */
#include "stdio.h"
#include "string.h"
#include "stdlib.h"
int card[1000];
int people[51];
void main()
{
int N,M;
int i,j,k,count,this_card,rest,temp;
int times=0;
char arr[1000],*p;
while( gets(arr) ){
/*input*/
p=strtok(arr," ");
N=atoi(p);
p=strtok(NULL," ");
M=atoi(p);
for(i=1;i<1000;i++){
p=strtok(NULL," ");
if(p==NULL) break;
card
=atoi(p);
}
/**initial**/
for(i=1;i<=N;i++)
people=i;
this_card=1;
rest=N;
/**START**/
do{
for(i=1,count=0;i<=N&&rest>M;i++){
if(people!=-1)
count++;
if(count==card[this_card]){
people=-1;
count=0;
rest--;
}
}/*for*/
this_card++;
}while(rest>M);
/****/
printf("Selection #%d\n",++times);
for(i=1,k=0;i<=N;i++){
if(people!=-1){
if(k>0) putchar(' ');
printf("%d",i);
k++;
}
}
printf("\n\n");
}
}
[/c]
Posted: Fri Dec 20, 2002 5:08 pm
by cym
Why?
Posted: Wed Apr 09, 2003 5:16 pm
by SeaViperz
sjn:
who can tell me what is the output for
25 1 7 7 7 7 8 8 8 8 9 9 9 9 10 10 10 10 11 11 11 11
Adrian Kuegel:
Output is:
Selection #1
1 2 3 4 5 6 11 19
Can someone please explain why this should happen?
Posted: Wed Apr 09, 2003 5:29 pm
by Eric
This is because after the 20 numbers have been "executed", this number still remain unchanged.
There is a test case that the number of card is less than 20. Take care about it also.
Re: WA Still
Posted: Tue Sep 09, 2003 2:42 pm
by InOutMoTo
manir wrote: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
This prob's special case is very much!
After many WAs , I got AC by handle out all special case above.
MUST BE CAREFUL that the conditions on Problem Set is not all matched!
Why is 402 - M*A*S*H Runtime error (SISEGV)?
Posted: Sun Oct 19, 2003 12:51 pm
by Daredevil
[cpp]
#include<stdio.h>
#include<malloc.h>
struct person{
int n;
struct person*next;
}*head,*tail,*cur;
void build(int p){
head=tail=cur=0;
for(int i=0;i<p;i++){
cur=(struct person*)malloc(sizeof(struct person));
cur->n=i+1;
if(!head) head=cur;
else tail->next=cur;
tail=cur;
tail->next=0;
}
}
void main(){
int p,s,count=0,card[22],i,j,k;
while(scanf("%i %i",&p,&s)==2){
if(count) printf("\n");
count++;
for(i=0;i<20;i++) scanf("%i",&card);
printf("Selection #%i\n",count);
build(p);
for(i=0,s=p-s;i<20&&s;i++){
j=card-2;
if(j==-1){
while(s){
cur=head->next;
free(head);
head=cur;
s--;
}
}
else{
cur=head;
while(cur->next){
for(k=0;k<j&&cur->next;cur=cur->next,k++);
if(cur->next){
tail=cur->next;
cur->next=tail->next;
free(tail);
cur=cur->next;
s--;
if(!s) break;
}
}
}
}
printf("%i",head->n);
cur=head->next;
free(head);
while(cur){
printf(" %i",cur->n);
head=cur->next;
free(cur);
cur=head;
}
printf("\n");
}
}
[/cpp]
Thnx!!
402 Why WA
Posted: Sun Apr 11, 2004 10:53 am
by mlvahe
Please help to find the bug in my program.
[cpp]
#include <iostream.h>
main()
{
int i, j, n, x, m, sld[51], cards[23], l, si;
bool b;
char c;
si = 1;
while (cin >> n >> x)
{
for (i = 1; i <= 50; i++)
sld = i;
i = -1;
b = false;
c = cin.get();
while (c != '\n')
{
if (('0'<=c) && (c <= '9'))
if (b)
cards = cards*10+c-'0';
else
cards[++i] = c - '0';
b = (('0'<=c) && (c <= '9'));
c = cin.get();
}
l = 0;
while (n > x)
{
m = cards[l++];
i = m;
while (n > x && i <= n)
{
for (j = i+1; j <= n; j++)
sld[j-1] = sld[j];
sld[n] = -1;
n--;
i += m-1;
}
}
cout << "Selection #" << si++ << "\n" << sld[1];
for (i = 2; i <= n; i++)
cout << " " << sld;
cout << "\n\n";
}
return 0;
}
[/cpp]
I'll be greatful if you told me a test case that my program doesn'e solve.