結果

問題 No.351 市松スライドパズル
ユーザー hogeover30hogeover30
提出日時 2017-06-17 01:52:39
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 124 ms / 2,000 ms
コード長 725 bytes
コンパイル時間 675 ms
コンパイル使用メモリ 78,860 KB
実行使用メモリ 11,004 KB
最終ジャッジ日時 2024-04-08 14:03:28
合計ジャッジ時間 3,765 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 96 ms
11,004 KB
testcase_01 AC 2 ms
6,548 KB
testcase_02 AC 2 ms
6,548 KB
testcase_03 AC 2 ms
6,548 KB
testcase_04 AC 2 ms
6,548 KB
testcase_05 AC 2 ms
6,548 KB
testcase_06 AC 2 ms
6,548 KB
testcase_07 AC 2 ms
6,548 KB
testcase_08 AC 2 ms
6,548 KB
testcase_09 AC 2 ms
6,548 KB
testcase_10 AC 2 ms
6,548 KB
testcase_11 AC 2 ms
6,548 KB
testcase_12 AC 2 ms
6,548 KB
testcase_13 AC 122 ms
10,824 KB
testcase_14 AC 121 ms
10,872 KB
testcase_15 AC 123 ms
11,000 KB
testcase_16 AC 124 ms
11,004 KB
testcase_17 AC 119 ms
11,004 KB
testcase_18 AC 119 ms
11,004 KB
testcase_19 AC 122 ms
11,004 KB
testcase_20 AC 124 ms
11,004 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;

int main()
{
    cin.sync_with_stdio(0);
    cin.tie(0);

    int h, w, n; cin>>h>>w>>n;
    vector<pair<char, int>> q(n);
    for(auto& e: q) {
        string s;
        int k;
        cin>>s>>k;
        e=make_pair(s[0], k);
    }
    reverse(begin(q), end(q));

    int r=0, c=0;
    for(auto& e: q) {
        int k=e.second;
        if (e.first=='R') {
            if (r==k) {
                --c;
                if (c<0) c+=w;
            }
        }
        else {
            if (c==k) {
                --r;
                if (r<0) r+=h;
            }
        }
    }
    cout<<((r+c)%2 ? "black" : "white")<<endl;
}
0