結果

問題 No.351 市松スライドパズル
ユーザー tetsuzuki1115tetsuzuki1115
提出日時 2017-10-03 06:56:01
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 369 ms / 2,000 ms
コード長 994 bytes
コンパイル時間 630 ms
コンパイル使用メモリ 78,260 KB
実行使用メモリ 13,176 KB
最終ジャッジ日時 2023-08-10 00:22:42
合計ジャッジ時間 6,640 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 278 ms
11,512 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,384 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 358 ms
12,392 KB
testcase_14 AC 363 ms
13,176 KB
testcase_15 AC 369 ms
12,432 KB
testcase_16 AC 367 ms
11,584 KB
testcase_17 AC 355 ms
11,904 KB
testcase_18 AC 356 ms
12,208 KB
testcase_19 AC 366 ms
11,896 KB
testcase_20 AC 366 ms
12,204 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <math.h>
#include <cmath>
#include <limits.h>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <functional>
#include <stdio.h>
using namespace std;

long long MOD = 1000000007;

int main() {
    
    vector< pair<int,int> > Q;
    int H,W,N;
    cin >> H >> W >> N;
    
    for ( int i = 0; i < N; i++ ) {
        string S;
        int K;
        cin >> S >> K;
        Q.push_back( make_pair( S == "R" ? 1 : 0, K ) );
    }
    int r = 0, c = 0;
    for ( int i = N-1; i >= 0; i-- ) {
        
        
        // cout << r << endl;
        // cout << c << endl;
        
        if ( (Q[i].first ? r : c)  == Q[i].second ) {
            if ( Q[i].first ) {
                c = (c+(W-1))%W;
            } 
            else {
                r = (r+(H-1))%H;
            }
        }
        
    }
    
    cout << ( (r+c)%2 ? "black" : "white" ) << endl;
    
    
    return 0;
}
0