10409 - Die Game

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

Moderator: Board moderators

Post Reply
r.z.
Learning poster
Posts: 56
Joined: Thu Jun 05, 2003 1:57 pm

10409 - Die Game

Post by r.z. »

why did I get WA?

the output seems to be alright....

mybe I miss something....can you tell me what it is?
[c]
#include<stdio.h>
#include<string.h>

void main()
{ int i,j,s=5,n=2,w=3,e=4,b=6,t=1,temp=0;
char command[6];

do{
scanf("%d",&i);
s=5;
n=2;
w=3;
e=4;
b=6;
t=1;
for(j=0;j<i;j++)
{
scanf("%s",command);
if(!strcmp(command,"north"))
{ temp=b;
b=n;
n=t;
t=s;
s=temp;
}
else if(!strcmp(command,"south"))
{ temp=b;
b=s;
s=t;
t=n;
n=temp;
}
else if(!strcmp(command,"west"))
{ temp=b;
b=w;
w=t;
t=e;
e=temp;
}
if(!strcmp(command,"east"))
{ temp=b;
b=e;
e=t;
t=w;
w=temp;
}
}
printf("%d\n",t);

}while(i!=0);
}
[/c]

Whinii F.
Experienced poster
Posts: 151
Joined: Wed Aug 21, 2002 12:07 am
Location: Seoul, Korea
Contact:

Post by Whinii F. »

inserting
if(i == 0) break;

after
scanf("%d",&i);

earned an AC. Try to figure out why. :)
JongMan @ Yonsei

soyoja
Experienced poster
Posts: 106
Joined: Sun Feb 17, 2002 2:00 am
Location: Seoul, South Korea
Contact:

Post by soyoja »

My idea is very similar to r.z.'s
It's so easy problem and I can solve it by simple simulation method.
But I think that it's so exciting problem. :)

oulongbin
Learning poster
Posts: 53
Joined: Sat Jul 10, 2004 5:57 pm
Location: Shanghai China

10409 WA

Post by oulongbin »

Why i always got WA??I don't the reason.
[cpp]
#include <iostream>
using namespace std;
#include <cstring>
int main()
{
int top=1,north=2,west=3;
char str[6];
int tt,nn,ww,n;
while(cin>>n&&n!=0)
{
cin.get();
tt=1,nn=2,ww=3;
for(;n>0;n--)
{

cin>>str;
switch(str[0])
{
case 'n':top=7-nn;north=tt;break;
case 'e':top=ww;west=7-tt;break;
case 's':top=nn;north=7-tt;break;
case 'w':top=7-ww;west=tt;break;
}
tt=top;nn=north;ww=west;
}
cout<<top<<endl;
}
return 0;
}

[/cpp]

Piotrek Mazur
New poster
Posts: 17
Joined: Thu Jul 15, 2004 10:55 am
Location: Poland, Rzeszow University of Technology

Post by Piotrek Mazur »

Test your program for this data:
1
north
3
north
east
south
4
north
east
south
north
0
Output should be:
5
1
3
I hope this help.

kiha
New poster
Posts: 37
Joined: Sat Dec 20, 2003 10:59 pm

Post by kiha »

Hi,

I got WA all the time. Can you please give me some test cases? What's the answer for

Code: Select all

1
west ?


Should it be 3 or 4?
I don't paste my code here as it is really long, much longer than ones on the board, I use more complicated method but it should be AC I think...

With regards ;)

---This part was added later---
OK now I got AC, stupid error :[
kiha

oulongbin
Learning poster
Posts: 53
Joined: Sat Jul 10, 2004 5:57 pm
Location: Shanghai China

Post by oulongbin »

Thank you.now i got AC.

plamplam
Experienced poster
Posts: 150
Joined: Fri May 06, 2011 11:37 am

Re: 10409 - Die Game

Post by plamplam »

Try these inputs

Code: Select all

1
north
1
east
1
south
1
west
5
north
south
east
west
south
2
south
east
2
south
west
2
north
north
3
east
east
east
4
east
east
south
west
10
east
west
east
north
north
west
south
north
north
west
0
Output should be:

Code: Select all

5
3
2
4
2
3
4
6
4
3
3
I got 2 Wrong Answers before AC because of a silly mistake. I assigned 3 to east instead of west(I actually thought west was in that direction :P). No critical inputs for this problem. Just make sure you are flipping the dice properly.
You tried your best and you failed miserably. The lesson is 'never try'. -Homer Simpson

Post Reply

Return to “Volume 104 (10400-10499)”