結果

問題 No.351 市松スライドパズル
ユーザー hotpepsihotpepsi
提出日時 2016-03-17 00:57:42
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 355 ms / 2,000 ms
コード長 543 bytes
コンパイル時間 915 ms
コンパイル使用メモリ 57,920 KB
実行使用メモリ 11,240 KB
最終ジャッジ日時 2023-10-25 07:41:46
合計ジャッジ時間 5,204 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 264 ms
11,240 KB
testcase_01 AC 2 ms
5,476 KB
testcase_02 AC 2 ms
5,476 KB
testcase_03 AC 2 ms
5,476 KB
testcase_04 AC 2 ms
5,476 KB
testcase_05 AC 2 ms
5,476 KB
testcase_06 AC 2 ms
5,476 KB
testcase_07 AC 2 ms
5,476 KB
testcase_08 AC 2 ms
5,476 KB
testcase_09 AC 2 ms
5,476 KB
testcase_10 AC 2 ms
5,476 KB
testcase_11 AC 3 ms
5,476 KB
testcase_12 AC 2 ms
5,476 KB
testcase_13 AC 346 ms
11,152 KB
testcase_14 AC 347 ms
11,172 KB
testcase_15 AC 353 ms
11,236 KB
testcase_16 AC 352 ms
11,240 KB
testcase_17 AC 348 ms
11,240 KB
testcase_18 AC 347 ms
11,240 KB
testcase_19 AC 355 ms
11,240 KB
testcase_20 AC 355 ms
11,240 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <sstream>
#include <cstring>

using namespace std;

int kind[1000000];
int seq[1000000];

int main(int argc, char *argv[])
{
	int H, W, N;
	cin >> H >> W >> N;
	for (int i = 0; i < N; ++i) {
		string S;
		cin >> S >> seq[i];
		kind[i] = S[0] == 'C';
	}
	int r = 0, c = 0;
	for (int i = N - 1; i >= 0; --i) {
		if (kind[i]) {
			if (seq[i] == c) {
				r = (r + H - 1) % H;
			}
		} else {
			if (seq[i] == r) {
				c = (c + W - 1) % W;
			}
		}
	}
	cout << (((r + c) % 2) ? "black" : "white") << endl;
	return 0;
}
0