結果

問題 No.351 市松スライドパズル
ユーザー nanophoto12nanophoto12
提出日時 2016-03-12 00:11:04
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 312 ms / 2,000 ms
コード長 1,558 bytes
コンパイル時間 673 ms
コンパイル使用メモリ 71,180 KB
実行使用メモリ 10,852 KB
最終ジャッジ日時 2023-10-25 07:21:42
合計ジャッジ時間 4,744 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 205 ms
10,852 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 1 ms
4,348 KB
testcase_05 AC 1 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 1 ms
4,348 KB
testcase_12 AC 1 ms
4,348 KB
testcase_13 AC 307 ms
10,852 KB
testcase_14 AC 304 ms
10,852 KB
testcase_15 AC 306 ms
10,852 KB
testcase_16 AC 304 ms
10,852 KB
testcase_17 AC 292 ms
10,852 KB
testcase_18 AC 291 ms
10,852 KB
testcase_19 AC 312 ms
10,852 KB
testcase_20 AC 298 ms
10,852 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <vector>
#include <set>
#include <map>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;

#define REP(i,x) for(int i=0;i<(int)(x);i++)

int h, w;
vector<int> hss;
vector<int> wss;

void dump()
{
    for(int y = 0;y < h;y++)
    {
        for(int x = 0;x < w;x++)
        {
            cout << (hss[y]^wss[x]);
        }
        cout << endl;
    }
}

int main(){
    cin >> h >> w;
    ll n;
    cin >> n;
    hss.resize(h);
    wss.resize(w);
    for(int i = 0;i < h;i++)
    {
        hss[i] = i % 2;
    }
    for(int i = 0;i < w;i++)
    {
        wss[i] = i % 2;
    }
    vector<pair<char, int>> vs(n);
    for(ll i = 0;i < n;i++)
    {
        char a;
        int k;
        cin >> a >> k;
        vs[i] = make_pair(a, k);
    }
    int r = 0;
    int c = 0;
    for(ll i = n-1;i >= 0;i--)
    {
        pair<char,int> p = vs[i];
        if(p.first == 'R')
        {
            if(r == p.second)
            {
                c--;
                if(c < 0)
                {
                    c = w-1;
                }
            }
        }
        else
        {
            if(c == p.second)
            {
                r--;
                if(r < 0)
                {
                    r = h - 1;
                }
            }
        }
        //cout << c << "," << r << endl;
    }
    //dump();

    auto color = (hss[r] ^ wss[c]);
    if(color)
    {
        cout << "black" << endl;
        return 0;
    }
    cout << "white" << endl;
    return 0;
    
}
0