結果
問題 |
No.351 市松スライドパズル
|
ユーザー |
![]() |
提出日時 | 2016-03-11 22:52:11 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 618 bytes |
コンパイル時間 | 530 ms |
コンパイル使用メモリ | 55,188 KB |
実行使用メモリ | 9,424 KB |
最終ジャッジ日時 | 2024-09-25 01:07:22 |
合計ジャッジ時間 | 3,241 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 WA * 1 |
other | AC * 12 WA * 5 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:14:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 14 | scanf("%d%d%d", &h, &w, &n); | ~~~~~^~~~~~~~~~~~~~~~~~~~~~ main.cpp:16:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 16 | scanf("%s%d", s[i], &val[i]); | ~~~~~^~~~~~~~~~~~~~~~~~~~~~~
ソースコード
//1マスに注目し、k回目に左上あったマスはk-1回目にどこにあったか?を考えるとO(N)で解ける。 #include <cstdio> #include <iostream> using namespace std; int h, w; int n; char s[1000000][2]; int val[1000000]; int main(){ int i; int r = 0, c = 0; scanf("%d%d%d", &h, &w, &n); for( i = 0; i < n; i++ ){ scanf("%s%d", s[i], &val[i]); } for( i = n - 1; i >= 0; i-- ){ if(s[i][0] == 'R'){ r = (r + h - (val[i] == r)) % h; } else{ c = (c + w - (val[i] == c)) % w; } } if( (r + c) % 2 ){ cout << "black" << endl; } else{ cout << "white" << endl; } return 0; }