結果

問題 No.351 市松スライドパズル
ユーザー maimai
提出日時 2016-03-11 23:25:42
言語 C++11
(gcc 13.3.0)
結果
AC  
実行時間 319 ms / 2,000 ms
コード長 807 bytes
コンパイル時間 797 ms
コンパイル使用メモリ 71,440 KB
実行使用メモリ 11,648 KB
最終ジャッジ日時 2024-09-25 02:37:21
合計ジャッジ時間 4,922 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 17
権限があれば一括ダウンロードができます

ソースコード

diff #


#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>
#include <stack>

using namespace std;
typedef unsigned char byte;
typedef long long int LLint;
typedef unsigned long long int uLLint;

class Twin{
    public:
    int c,k;
    Twin(int a,int b):c(a),k(b){}
};

int main(){
    int h,w,n,k;
    char c;
    int i;
    int x,y;
    stack<Twin> stk;
    
    cin>>h>>w>>n;
    
    for (i=0;i<n;i++){
        cin>>c>>k;
        stk.push(Twin((int)c,k));
    }
    x=y=0;
    for (;!stk.empty();stk.pop()){
        Twin &t=stk.top();
        if (t.c=='R'){
            if (y==t.k) x--;
        }else{
            if (x==t.k) y--;
        }
        if (x<0) x=w-1;
        if (y<0) y=h-1;
    }
    
    cout<<( ((x&1)^(y&1))?"black":"white" )<<endl;
    return 0;
}
0