Anyone please give some special I/O............
getting wa and wa.....
11459 - Snakes and Ladders
Moderator: Board moderators
Re: 11459 - Snakes and Ladders
Code: Select all
keep dreaming...
Re: 11459 - Snakes and Ladders
the biggest trick is that the input is formatted nicely for you already ...
Be very careful of the meaning of mouth/tail of snake.
The input is specified as X, Y where X is bottom of ladder or mouth of snake (Entrance)
Y is top of ladder or tail of snake (Exit)
Also terminate ASAP when a player reaches 100
Be very careful of the meaning of mouth/tail of snake.
The input is specified as X, Y where X is bottom of ladder or mouth of snake (Entrance)
Y is top of ladder or tail of snake (Exit)
Also terminate ASAP when a player reaches 100
11459 - Snakes and Ladders
This is so frustrating , I didn't understand what is the problem , why I am getting WA .
Anybody plz help me out . give me some critical I/O
Anybody plz help me out . give me some critical I/O
Code: Select all
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <cstdio>
using namespace std;
int main()
{
// freopen("input.txt","r",stdin);
// freopen("output.txt","w",stdout);
vector<int>snake_mouth,snake_tail,ladd_start,ladd_end;
vector<int>token_position;
long long int number_of_player,number_of_snakes,number_die_rolls;
long long int cases,start,end,temp,die_roll,mod,flag,vut,j;
while(cin>>cases){
while(cases--)
{
cin>>number_of_player>>number_of_snakes>>number_die_rolls;
while(number_of_snakes--)
{
cin>>start>>end;
if(start>end)
{
snake_mouth.push_back(start);
snake_tail.push_back(end);
}
else
{
ladd_start.push_back(start);
ladd_end.push_back(end);
}
}
temp=number_die_rolls;
while(number_die_rolls--)
{
token_position.push_back(1);
}
for( j=0;j<token_position.size();j++)
{
flag=0;
cin>>die_roll;
mod=(j+1)%number_of_player;
if(mod==0)
{
token_position[number_of_player-1]=token_position[number_of_player-1]+die_roll;
for(int i=0;i<snake_mouth.size();i++)
{
if((token_position[number_of_player-1])==snake_mouth[i])
{
token_position[number_of_player-1]=snake_tail[i];
flag=1;
break;
}
}
for(int i=0;i<ladd_start.size();i++)
{
if(flag==1)
{
break;
}
if((token_position[number_of_player-1])==ladd_start[i])
{
token_position[temp-1]=ladd_end[i];
break;
}
}
if(token_position[number_of_player-1]>=100)
{
token_position[number_of_player-1]=100;
vut=temp-(j+1);
while(vut--)
{
cin>>die_roll;
}
break;
}
}
else
{
token_position[mod-1]=token_position[mod-1]+die_roll;
for(int i=0;i<snake_mouth.size();i++)
{
if((token_position[mod-1])==snake_mouth[i])
{
token_position[mod-1]=snake_tail[i];
flag=1;
break;
}
}
for(int i=0;i<ladd_start.size();i++)
{
if(flag==1)
{
break;
}
if((token_position[mod-1])==ladd_start[i])
{
token_position[mod-1]=ladd_end[i];
break;
}
}
if(token_position[mod-1]>=100)
{
token_position[mod-1]=100;
vut=temp-(j+1);
while(vut--)
{
cin>>die_roll;
}
break;
}
}
}
for(int i=1;i<=number_of_player;i++)
{
cout<<"Position of player "<<i<<" is "<<token_position[i-1]<<"."<<endl;
}
snake_mouth.clear();
snake_tail.clear();
ladd_start.clear();
ladd_end.clear();
token_position.clear();
}
}
return 0;
}
-
- Guru
- Posts: 5947
- Joined: Thu Sep 01, 2011 9:09 am
- Location: San Jose, CA, USA
Re: 11459 - Snakes and Ladders
Input:AC output:
Code: Select all
10
17 5 12
83 87
81 40
59 96
3 24
9 80
4
1
4
2
3
4
6
3
5
4
1
3
16 6 10
89 30
21 81
15 41
20 56
22 58
69 72
2
4
4
3
1
2
6
3
4
3
7 1 3
80 42
4
1
3
21 0 14
1
2
4
2
6
2
4
1
2
3
2
3
4
4
3 9 0
65 22
25 64
6 36
45 46
17 53
26 69
7 34
41 40
92 42
2 0 19
3
2
1
1
4
2
4
4
5
2
1
1
6
1
6
6
5
6
2
11 4 1
76 87
22 83
79 19
78 91
1
12 6 14
98 47
23 29
31 39
79 91
74 88
50 77
6
4
2
2
3
6
2
4
1
6
5
2
6
3
21 2 0
55 51
67 48
2 2 6
29 46
84 27
5
5
1
4
6
6
Code: Select all
Position of player 1 is 5.
Position of player 2 is 2.
Position of player 3 is 5.
Position of player 4 is 24.
Position of player 5 is 4.
Position of player 6 is 5.
Position of player 7 is 7.
Position of player 8 is 4.
Position of player 9 is 6.
Position of player 10 is 5.
Position of player 11 is 2.
Position of player 12 is 4.
Position of player 13 is 1.
Position of player 14 is 1.
Position of player 15 is 1.
Position of player 16 is 1.
Position of player 17 is 1.
Position of player 1 is 3.
Position of player 2 is 5.
Position of player 3 is 5.
Position of player 4 is 4.
Position of player 5 is 2.
Position of player 6 is 3.
Position of player 7 is 7.
Position of player 8 is 4.
Position of player 9 is 5.
Position of player 10 is 4.
Position of player 11 is 1.
Position of player 12 is 1.
Position of player 13 is 1.
Position of player 14 is 1.
Position of player 15 is 1.
Position of player 16 is 1.
Position of player 1 is 5.
Position of player 2 is 2.
Position of player 3 is 4.
Position of player 4 is 1.
Position of player 5 is 1.
Position of player 6 is 1.
Position of player 7 is 1.
Position of player 1 is 2.
Position of player 2 is 3.
Position of player 3 is 5.
Position of player 4 is 3.
Position of player 5 is 7.
Position of player 6 is 3.
Position of player 7 is 5.
Position of player 8 is 2.
Position of player 9 is 3.
Position of player 10 is 4.
Position of player 11 is 3.
Position of player 12 is 4.
Position of player 13 is 5.
Position of player 14 is 5.
Position of player 15 is 1.
Position of player 16 is 1.
Position of player 17 is 1.
Position of player 18 is 1.
Position of player 19 is 1.
Position of player 20 is 1.
Position of player 21 is 1.
Position of player 1 is 1.
Position of player 2 is 1.
Position of player 3 is 1.
Position of player 1 is 38.
Position of player 2 is 26.
Position of player 1 is 2.
Position of player 2 is 1.
Position of player 3 is 1.
Position of player 4 is 1.
Position of player 5 is 1.
Position of player 6 is 1.
Position of player 7 is 1.
Position of player 8 is 1.
Position of player 9 is 1.
Position of player 10 is 1.
Position of player 11 is 1.
Position of player 1 is 13.
Position of player 2 is 8.
Position of player 3 is 3.
Position of player 4 is 3.
Position of player 5 is 4.
Position of player 6 is 7.
Position of player 7 is 3.
Position of player 8 is 5.
Position of player 9 is 2.
Position of player 10 is 7.
Position of player 11 is 6.
Position of player 12 is 3.
Position of player 1 is 1.
Position of player 2 is 1.
Position of player 3 is 1.
Position of player 4 is 1.
Position of player 5 is 1.
Position of player 6 is 1.
Position of player 7 is 1.
Position of player 8 is 1.
Position of player 9 is 1.
Position of player 10 is 1.
Position of player 11 is 1.
Position of player 12 is 1.
Position of player 13 is 1.
Position of player 14 is 1.
Position of player 15 is 1.
Position of player 16 is 1.
Position of player 17 is 1.
Position of player 18 is 1.
Position of player 19 is 1.
Position of player 20 is 1.
Position of player 21 is 1.
Position of player 1 is 13.
Position of player 2 is 16.
Check input and AC output for thousands of problems on uDebug!
Re: 11459 - Snakes and Ladders
brianfry713,
Thanks so much for these great test cases.
Also, anyone else looking for test cases, please be sure to consider checking out the other thread on this problem here
http://online-judge.uva.es/board/viewto ... ilit=11459
There's a great test case by jurajz that you might (absolutely) want to look into, also.
Thanks so much for these great test cases.
Also, anyone else looking for test cases, please be sure to consider checking out the other thread on this problem here
http://online-judge.uva.es/board/viewto ... ilit=11459
There's a great test case by jurajz that you might (absolutely) want to look into, also.
Re: 11459 - Snakes and Ladders
jurajz,
Thanks for this great test case.
Also, anyone looking for test cases on this problem, please be sure to consider checking out the other thread on this problem here
http://online-judge.uva.es/board/viewto ... 51#p368251
brianfry713's shared some excellent test cases there.
Thanks for this great test case.
Also, anyone looking for test cases on this problem, please be sure to consider checking out the other thread on this problem here
http://online-judge.uva.es/board/viewto ... 51#p368251
brianfry713's shared some excellent test cases there.
Re: 11459 - Snakes and Ladders
do I need to terminate as soon any player reaches 100..?
Re: 11459 - Snakes and Ladders
From the problem statement: A player wins when his or her token reached the square numbered 100. At that point, the game ends.axelblaze wrote:do I need to terminate as soon any player reaches 100..?
-
- Experienced poster
- Posts: 148
- Joined: Sun Jul 13, 2014 4:32 am
- Location: Rangpur, Bangladesh
Re: 11459 - Snakes and Ladders
Code: Select all
Removed after AC
Last edited by Shahidul.CSE on Thu Sep 04, 2014 5:47 pm, edited 2 times in total.
Md. Shahidul Islam
Dept. of CSE at Begum Rokeya University, Rangpur, Bangladesh
UVa id: http://uhunt.felix-halim.net/id/438420
My facebook account,
Email me: shahidul.cse.brur@gmail.com
Dept. of CSE at Begum Rokeya University, Rangpur, Bangladesh
UVa id: http://uhunt.felix-halim.net/id/438420
My facebook account,
Email me: shahidul.cse.brur@gmail.com
-
- Experienced poster
- Posts: 148
- Joined: Sun Jul 13, 2014 4:32 am
- Location: Rangpur, Bangladesh
Re: 11459 - Snakes and Ladders
Code: Select all
Code removed !
Last edited by Shahidul.CSE on Thu Sep 04, 2014 5:44 pm, edited 1 time in total.
Md. Shahidul Islam
Dept. of CSE at Begum Rokeya University, Rangpur, Bangladesh
UVa id: http://uhunt.felix-halim.net/id/438420
My facebook account,
Email me: shahidul.cse.brur@gmail.com
Dept. of CSE at Begum Rokeya University, Rangpur, Bangladesh
UVa id: http://uhunt.felix-halim.net/id/438420
My facebook account,
Email me: shahidul.cse.brur@gmail.com
-
- Guru
- Posts: 5947
- Joined: Thu Sep 01, 2011 9:09 am
- Location: San Jose, CA, USA
Re: 11459 - Snakes and Ladders
Input:AC output:
Code: Select all
10
5 0 3
1
3
3
11 8 19
45 4
27 33
7 22
67 50
68 86
54 63
85 35
51 69
5
6
2
5
1
6
3
5
6
5
5
5
1
4
3
4
3
6
3
11 8 3
23 14
84 75
32 25
64 37
93 34
94 60
51 58
8 79
2
6
6
15 9 17
14 37
13 24
20 97
41 64
94 18
33 34
91 63
58 12
98 7
1
5
6
6
5
4
3
4
2
1
1
3
2
3
3
3
5
8 7 19
97 16
69 30
48 17
47 6
27 99
19 7
31 75
4
4
3
6
5
5
2
3
1
4
3
6
4
6
2
4
1
5
1
15 1 7
77 82
5
1
5
4
4
2
5
5 0 0
2 0 8
2
2
4
3
2
1
4
5
16 5 5
68 19
14 6
58 89
42 83
93 84
5
6
2
3
1
10 7 10
16 89
29 73
32 86
84 27
57 9
14 79
17 26
2
5
5
5
6
6
3
4
3
3
Code: Select all
Position of player 1 is 2.
Position of player 2 is 4.
Position of player 3 is 4.
Position of player 4 is 1.
Position of player 5 is 1.
Position of player 1 is 11.
Position of player 2 is 23.
Position of player 3 is 22.
Position of player 4 is 9.
Position of player 5 is 6.
Position of player 6 is 25.
Position of player 7 is 10.
Position of player 8 is 9.
Position of player 9 is 22.
Position of player 10 is 6.
Position of player 11 is 6.
Position of player 1 is 3.
Position of player 2 is 7.
Position of player 3 is 7.
Position of player 4 is 1.
Position of player 5 is 1.
Position of player 6 is 1.
Position of player 7 is 1.
Position of player 8 is 1.
Position of player 9 is 1.
Position of player 10 is 1.
Position of player 11 is 1.
Position of player 1 is 5.
Position of player 2 is 11.
Position of player 3 is 7.
Position of player 4 is 7.
Position of player 5 is 6.
Position of player 6 is 5.
Position of player 7 is 4.
Position of player 8 is 5.
Position of player 9 is 3.
Position of player 10 is 2.
Position of player 11 is 2.
Position of player 12 is 4.
Position of player 13 is 3.
Position of player 14 is 4.
Position of player 15 is 4.
Position of player 1 is 7.
Position of player 2 is 14.
Position of player 3 is 8.
Position of player 4 is 13.
Position of player 5 is 10.
Position of player 6 is 12.
Position of player 7 is 5.
Position of player 8 is 8.
Position of player 1 is 6.
Position of player 2 is 2.
Position of player 3 is 6.
Position of player 4 is 5.
Position of player 5 is 5.
Position of player 6 is 3.
Position of player 7 is 6.
Position of player 8 is 1.
Position of player 9 is 1.
Position of player 10 is 1.
Position of player 11 is 1.
Position of player 12 is 1.
Position of player 13 is 1.
Position of player 14 is 1.
Position of player 15 is 1.
Position of player 1 is 1.
Position of player 2 is 1.
Position of player 3 is 1.
Position of player 4 is 1.
Position of player 5 is 1.
Position of player 1 is 13.
Position of player 2 is 12.
Position of player 1 is 6.
Position of player 2 is 7.
Position of player 3 is 3.
Position of player 4 is 4.
Position of player 5 is 2.
Position of player 6 is 1.
Position of player 7 is 1.
Position of player 8 is 1.
Position of player 9 is 1.
Position of player 10 is 1.
Position of player 11 is 1.
Position of player 12 is 1.
Position of player 13 is 1.
Position of player 14 is 1.
Position of player 15 is 1.
Position of player 16 is 1.
Position of player 1 is 3.
Position of player 2 is 6.
Position of player 3 is 6.
Position of player 4 is 6.
Position of player 5 is 7.
Position of player 6 is 7.
Position of player 7 is 4.
Position of player 8 is 5.
Position of player 9 is 4.
Position of player 10 is 4.
Check input and AC output for thousands of problems on uDebug!
-
- Experienced poster
- Posts: 148
- Joined: Sun Jul 13, 2014 4:32 am
- Location: Rangpur, Bangladesh
Re: 11459 - Snakes and Ladders
Thanks brianfry713, got accepted !!
![:D](./images/smilies/icon_biggrin.gif)
![:D](./images/smilies/icon_biggrin.gif)
![:D](./images/smilies/icon_biggrin.gif)
Md. Shahidul Islam
Dept. of CSE at Begum Rokeya University, Rangpur, Bangladesh
UVa id: http://uhunt.felix-halim.net/id/438420
My facebook account,
Email me: shahidul.cse.brur@gmail.com
Dept. of CSE at Begum Rokeya University, Rangpur, Bangladesh
UVa id: http://uhunt.felix-halim.net/id/438420
My facebook account,
Email me: shahidul.cse.brur@gmail.com
Re: 11459 - Snakes and Ladders
Tried all the test cases available here. Still WA (6 times
).
![:(](./images/smilies/icon_frown.gif)
Code: Select all
#include <cstdio>
#include <iostream>
#include <map>
#define MAX 1000000
using namespace std;
int main(){
char player[MAX+2];
int die;
int testcase;
int numplayers,numsnld,numdierol;
map <int,int> cellmp;
cin>>testcase;
//freopen("a.out","w",stdout);
while(testcase--){
scanf("%d %d %d",&numplayers,&numsnld,&numdierol);
bool end = false;
while(numsnld--){
int from,to;
scanf("%d %d",&from,&to);
cellmp[from] = to;
}
for(int i=1;i<=numplayers;i++)
player[i] = 1;
//cout<<"numplayers: "<<numplayers<<endl;
for(int i=0;i<numdierol;i++){
int playernum = i%(numplayers)+1;
int face;
scanf("%d",&face);
int next = player[playernum]+face;
if(!end){
// cout<<"next: "<<next<<endl;
int v = cellmp[next];
if(v){
//cout<<playernum<<"was at "<<(int)player[playernum]<<" now at: "<<v<<endl;
player[playernum] = v>100?100:v;
}
else{
//cout<<playernum<<"was at "<<(int)player[playernum]<<" now at: "<<next<<endl;
player[playernum] = next>100?100:next;
}
if(player[playernum]==100)
end = true;
}
}
for(int i=1;i<=numplayers;i++){
printf("Position of player %d is %d.\n",i,player[i]);
player[i] = 1;
}
cellmp.clear();
}
}
-
- Guru
- Posts: 5947
- Joined: Thu Sep 01, 2011 9:09 am
- Location: San Jose, CA, USA
Re: 11459 - Snakes and Ladders
That is AC code.
Check input and AC output for thousands of problems on uDebug!