Page 3 of 3

### Re: 11459 - Snakes and Ladders

Posted: Sun Nov 23, 2014 2:44 pm
Critical test case based on the point "The sequence of die rolls may also continue
after the game is over; in this case, the die rolls after the end of the game should be ignored."

Code: Select all

``````2
3 3 3
2 100
3 99
4 98
1
2
3
3 3 3
2 5
3 6
4 7
1
2
3
``````
My AC output:

Code: Select all

``````Position of player 1 is 100.
Position of player 2 is 1.
Position of player 3 is 1.
Position of player 1 is 5.
Position of player 2 is 6.
Position of player 3 is 7.
``````

### 11459 - Snakes and Ladders

Posted: Sun Feb 01, 2015 10:05 pm
Help me please...where is the problem??? I got WA for this code:

Code: Select all

``````using namespace std;
#include<bits/stdc++.h>

#define maxx 1000050
int player[maxx], mapp;

int main()
{
//freopen("in.txt", "r", stdin);
//freopen("out.txt", "w", stdout);
int a, b, c;
int cnum; scanf("%d", &cnum);
for(int cs = 1; cs <= cnum; cs++)
{
scanf("%d %d %d", &a, &b, &c);

for(int i = 1 ; i <= a; i++) player[i] = 1;
for(int i = 1; i <= 110; i++) mapp[i] = i;

for(int i = 1, x, y; i <= b; i++)
{
scanf("%d %d", &x, &y);
mapp[x] = y;
}
bool flag = true;
for(int i = 1, x, p = 0; i <= c; i++, p++)
{
scanf("%d", &x);
if(flag)
{
int cal = p % a + 1;
if((player[cal] + x) >= 100)
{
player[cal] = 100;
flag = false;
}
else
player[cal] = mapp[player[cal] + x];
}
}

for(int i = 1; i <= a; i++)
{
printf("Position of player %d is %d.\n", i, player[i]);
}
}
return 0;
}
``````

### Re: 11459 - Snakes and Ladders

Posted: Tue Feb 03, 2015 12:18 am
Next time post in the existing thread.
Input:

Code: Select all

``````1
2 1 2
2 100
1
1
``````
AC output:

Code: Select all

``````Position of player 1 is 100.
Position of player 2 is 1.
``````

### Re: 11459 - Snakes and Ladders

Posted: Sat Nov 21, 2015 11:34 pm
Any idea why i'm getting a WA ? help please! Code: Select all

``````#include<cstdio>
#include<iostream>
#include<algorithm>
long long int p;
using namespace std;

int main()
{
long long int player,sl,moves,ludu,a,b,wow,j,i,test,t,flag;

scanf("%lld",&test);
for(t=0;t<test;t++)
{
flag=0;
for(i=1;i<=100;i++) ludu[i]=i;
for(i=1;i<=1000000;i++) p[i]=1;

scanf("%lld%lld%lld",&player,&sl,&moves);

for(i=1;i<=sl;i++)
{
scanf("%lld%lld",&a,&b);
ludu[a]=b;
}
j=1;
for(i=1;i<=moves;i++)
{
if(flag==0) p[j]=ludu[p[j]];
scanf("%lld",&wow);
if(flag==0){
p[j]=p[j]+wow;
p[j]=ludu[p[j]];
}
if(p[j]>=100){
p[j]=100;
flag=1;
}
j++;
if(j>player) j=1;
}
for(j=1;j<=player;j++){
printf("Position of player %lld is %lld.\n",j,p[j]);
p[j]=1;
}
}
return 0;
}
``````