結果

問題 No.351 市松スライドパズル
ユーザー hogeover30hogeover30
提出日時 2016-05-21 16:19:12
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
CE  
(最新)
AC  
(最初)
実行時間 -
コード長 553 bytes
コンパイル時間 461 ms
コンパイル使用メモリ 58,904 KB
最終ジャッジ日時 2023-10-25 07:46:18
合計ジャッジ時間 1,431 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。

コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:9:5: error: 'vector' was not declared in this scope
    9 |     vector<pair<char, int>> q(n);
      |     ^~~~~~
main.cpp:3:1: note: 'std::vector' is defined in header '<vector>'; did you forget to '#include <vector>'?
    2 | #include <algorithm>
  +++ |+#include <vector>
    3 | #include <string>
main.cpp:9:26: error: expected primary-expression before '>' token
    9 |     vector<pair<char, int>> q(n);
      |                          ^~
main.cpp:9:29: error: 'q' was not declared in this scope
    9 |     vector<pair<char, int>> q(n);
      |                             ^

ソースコード

diff #

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

int main()
{
    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=(c-1+w)%w;
        }
        else {
            if (c==k) r=(r-1+h)%h;
        }
    }
    cout<<((r+c)%2 ? "black" : "white")<<endl;
}
0