結果

問題 No.351 市松スライドパズル
ユーザー data9824data9824
提出日時 2016-04-07 02:05:25
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 360 ms / 2,000 ms
コード長 678 bytes
コンパイル時間 538 ms
コンパイル使用メモリ 63,048 KB
実行使用メモリ 11,556 KB
最終ジャッジ日時 2023-10-25 07:44:40
合計ジャッジ時間 5,227 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 259 ms
11,556 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 1 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 1 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 2 ms
4,348 KB
testcase_12 AC 2 ms
4,348 KB
testcase_13 AC 350 ms
11,556 KB
testcase_14 AC 352 ms
11,556 KB
testcase_15 AC 358 ms
11,556 KB
testcase_16 AC 359 ms
11,556 KB
testcase_17 AC 355 ms
11,556 KB
testcase_18 AC 357 ms
11,556 KB
testcase_19 AC 358 ms
11,556 KB
testcase_20 AC 360 ms
11,556 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <string>
#include <utility>

using namespace std;

int main() {
	int h, w, n;
	cin >> h >> w >> n;
	vector<pair<char, int> > operations;
	for (int i = 0; i < n; ++i) {
		string s;
		int k;
		cin >> s >> k;
		operations.push_back(make_pair(s[0], k));
	}
	int x = 0;
	int y = 0;
	for (int i = operations.size() - 1; i >= 0; --i) {
		if (operations[i].first == 'R') {
			if (operations[i].second == y) {
				--x;
				if (x < 0) {
					x = w - 1;
				}
			}
		} else {
			if (operations[i].second == x) {
				--y;
				if (y < 0) {
					y = h - 1;
				}
			}
		}
	}
	cout << ((x + y) % 2 == 0 ? "white" : "black") << endl;
	return 0;
}
0