11459 - Snakes and Ladders

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

Moderator: Board moderators

bradd123
New poster
Posts: 17
Joined: Thu Jul 03, 2014 11:13 am

Re: 11459 - Snakes and Ladders

Post by bradd123 » 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.

shikhorroy
New poster
Posts: 27
Joined: Sat Jul 27, 2013 3:52 am

11459 - Snakes and Ladders

Post by shikhorroy » 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[111];

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;
}

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 11459 - Snakes and Ladders

Post by brianfry713 » 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.
Check input and AC output for thousands of problems on uDebug!

qshahrukh40
New poster
Posts: 2
Joined: Sun Nov 15, 2015 6:24 pm

Re: 11459 - Snakes and Ladders

Post by qshahrukh40 » 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[1000000];
using namespace std;

int main()
{
    long long int player,sl,moves,ludu[200],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;
}

Post Reply

Return to “Volume 114 (11400-11499)”