IARCS (A Board Game)



/* Question:
http://www.iarcs.org.in/inoi/contests/oct2004/Basic-2.php
Author : Tausiq */

#include <stdio.h>

int main ()
{
    int N, M;
    scanf ("%i %i", &N, &M);

    char N_array [10005];

    for ( int i = 1; i <= N; i++ ) {
        char temp;

        while ( scanf ("%c", &temp) ) {
            if ( temp == '+' || temp == '-' )
                break;
        }

        N_array &#91;i&#93; = temp;
    }

    int j = 1; // token
    int d; // dice
    int count = 1;

    for ( int i = 0; i < M; i++ ) {
        scanf ("%i", &d);

        if ( N_array &#91;j&#93; == '+' && j + d <= N )
            j += d;

        else if ( N_array &#91;j&#93; == '-' && j - d >= 1 )
            j -= d;

        if ( j == 1 )
            count++;
    }

    printf ("%i\n", count);

    return 0;
}

Advertisements

3 thoughts on “IARCS (A Board Game)

  1. it’s not clear to me actually what do u want ?
    solution for the respective problem is given with Problem statement’s link
    you will also find judge’s input / output there.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s