結果

問題 No.351 市松スライドパズル
ユーザー tetsuzuki1115
提出日時 2017-10-03 06:56:01
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 378 ms / 2,000 ms
コード長 994 bytes
コンパイル時間 686 ms
コンパイル使用メモリ 82,880 KB
実行使用メモリ 13,088 KB
最終ジャッジ日時 2024-11-15 22:58:49
合計ジャッジ時間 6,952 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 17
権限があれば一括ダウンロードができます

ソースコード

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