結果
| 問題 |
No.351 市松スライドパズル
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-04-14 01:39:54 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 117 ms / 2,000 ms |
| コード長 | 742 bytes |
| コンパイル時間 | 789 ms |
| コンパイル使用メモリ | 76,008 KB |
| 最終ジャッジ日時 | 2025-01-09 18:20:58 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 17 |
ソースコード
#include <iostream>
#include <algorithm>
#include <vector>
void solve() {
int h, w;
std::cin >> h >> w;
int n;
std::cin >> n;
std::vector<std::pair<char, int>> ps(n);
for (auto& p : ps) std::cin >> p.first >> p.second;
std::reverse(ps.begin(), ps.end());
int x = 0, y = 0;
for (auto p : ps) {
if (p.first == 'R') {
if (p.second != x) continue;
if (--y < 0) y += w;
} else {
if (p.second != y) continue;
if (--x < 0) x += h;
}
}
std::cout << ((x + y) % 2 == 0 ? "white" : "black")
<< std::endl;
}
int main() {
std::cin.tie(nullptr);
std::ios::sync_with_stdio(false);
solve();
return 0;
}