結果

問題 No.351 市松スライドパズル
ユーザー startcppstartcpp
提出日時 2016-03-11 22:52:11
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 618 bytes
コンパイル時間 1,679 ms
コンパイル使用メモリ 54,900 KB
実行使用メモリ 9,596 KB
最終ジャッジ日時 2023-10-25 05:43:36
合計ジャッジ時間 3,055 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 123 ms
9,516 KB
testcase_01 AC 2 ms
5,712 KB
testcase_02 AC 2 ms
5,712 KB
testcase_03 AC 2 ms
5,712 KB
testcase_04 WA -
testcase_05 AC 2 ms
5,712 KB
testcase_06 AC 2 ms
5,712 KB
testcase_07 AC 2 ms
5,712 KB
testcase_08 AC 2 ms
5,712 KB
testcase_09 AC 2 ms
5,712 KB
testcase_10 AC 2 ms
5,712 KB
testcase_11 AC 2 ms
5,712 KB
testcase_12 WA -
testcase_13 AC 136 ms
9,476 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 142 ms
9,516 KB
testcase_18 AC 144 ms
9,516 KB
testcase_19 WA -
testcase_20 AC 139 ms
9,516 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
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]);
      |                 ~~~~~^~~~~~~~~~~~~~~~~~~~~~~

ソースコード

diff #

//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;
}
0