結果
問題 | No.351 市松スライドパズル |
ユーザー |
![]() |
提出日時 | 2016-03-11 22:46:53 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 135 ms / 2,000 ms |
コード長 | 655 bytes |
コンパイル時間 | 652 ms |
コンパイル使用メモリ | 53,332 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-09-25 02:28:49 |
合計ジャッジ時間 | 2,907 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 17 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:18:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 18 | scanf("%d %d", &H, &W); | ~~~~~^~~~~~~~~~~~~~~~~ main.cpp:19:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 19 | scanf("%d", &N); | ~~~~~^~~~~~~~~~ main.cpp:22:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 22 | scanf("%s %d", t, &K[i]); | ~~~~~^~~~~~~~~~~~~~~~~~~
ソースコード
#include <cstdio>#include <cstring>#include <vector>#include <string>#include <stack>#include <queue>#include <algorithm>int H, W;int N;char S[1048576];int K[1048576];int main() {// step 1scanf("%d %d", &H, &W);scanf("%d", &N);for(int i = 0; i < N; ++i) {char t[2];scanf("%s %d", t, &K[i]);S[i] = t[0];}// step 2int r = 0, c = 0;for(int i = N - 1; i >= 0; --i) {if( S[i] == 'R' and r == K[i] ) {c = (c + (W - 1)) % W;}if( S[i] == 'C' and c == K[i] ) {r = (r + (H - 1)) % H;}}// step 3printf("%s\n", ((c + r) % 2 == 0 ? "white" : "black"));return 0;}