結果
問題 | No.351 市松スライドパズル |
ユーザー | __math |
提出日時 | 2016-03-11 22:32:58 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 138 ms / 2,000 ms |
コード長 | 675 bytes |
コンパイル時間 | 1,378 ms |
コンパイル使用メモリ | 163,008 KB |
実行使用メモリ | 13,008 KB |
最終ジャッジ日時 | 2024-09-25 02:26:51 |
合計ジャッジ時間 | 3,912 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 17 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:18:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 18 | scanf(" %c%d", &s, &k); | ~~~~~^~~~~~~~~~~~~~~~~
ソースコード
#include <bits/stdc++.h> using namespace std; #define FOR(i,n) for(int i = 0 ;i < (n); i++) #define sz(c) ((int)c.size()) #define ten(n) ((int)1e##n) typedef long long ll; typedef pair<ll, ll> Pll; typedef pair<int, int> Pii; int main() { int h, w, n; cin >> h >> w >> n; vector<pair<char,int>> vp; FOR(i, n) { char s; int k; scanf(" %c%d", &s, &k); vp.emplace_back(s, k); } reverse(vp.begin(), vp.end()); int x = 0, y = 0; for (auto& sk : vp) { if (sk.first == 'R') { if (sk.second == x) y = (y + w - 1) % w; } else { if (sk.second == y) x = (x + h - 1) % h; } } bool black = (x + y) % 2 == 1; puts(black ? "black" : "white"); return 0; }