結果

問題 No.351 市松スライドパズル
ユーザー hotpepsi
提出日時 2016-03-17 00:57:42
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 357 ms / 2,000 ms
コード長 543 bytes
コンパイル時間 532 ms
コンパイル使用メモリ 58,536 KB
実行使用メモリ 11,164 KB
最終ジャッジ日時 2024-09-25 02:57:58
合計ジャッジ時間 5,029 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 17
権限があれば一括ダウンロードができます

ソースコード

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