#1188281

Solution for 1129: Hanafuda Shuffle by capythm

Source Code Status Test Cases
    Policy: public     Reviewed: 128    
00.00 sec    1160 KB    29 lines     542 bytes    2015-01-15 22:57
#include <iostream>
using namespace std;
int main( void )
{
  while( 1 ){
    int n,r,p,c;
    int d[2][55];
    cin >> n >> r;
    if( n == 0 ) break;
    for( int i=0; i<n; i++ ){
      d[0][i] = n-i;
    }
    for( int i=0; i<r; i++ ){
      cin >> p >> c;
      int k = i & 1;
      for( int j=0; j<c; j++ ){
        d[1-k][j] = d[k][j+p-1];
      }
      for( int j=0; j<p-1; j++ ){
        d[1-k][j+c] = d[k][j];
      }
      for( int j=c+p-1; j<n; j++ ){
        d[1-k][j] = d[k][j];
      }
    }
    cout << d[r&1][0] << endl;
  }
}

Compile Error Logs:
You are not authorized to see the message.

Status
Judge: 1/1 C++ CPU: 00.00 sec Memory: 1160 KB Length: 542 B 2015-01-15 22:57 2015-01-15 22:57
Results for testcases
Case # Verdict CPU Time Memory In Out Case Name
Case #1: : Accepted 00.00 sec 1160 KB
< prev | / | next >  
 
Judge Input #  ( | ) Judge Output #  ( | )


Comments
 
 Under Construction.
 
Categories
 
 
Free Tags