結果

問題 No.351 市松スライドパズル
ユーザー 👑 はまやんはまやんはまやんはまやん
提出日時 2016-03-13 17:19:37
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 392 ms / 2,000 ms
コード長 647 bytes
コンパイル時間 2,095 ms
コンパイル使用メモリ 164,280 KB
実行使用メモリ 42,224 KB
最終ジャッジ日時 2023-10-25 07:39:28
合計ジャッジ時間 6,603 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 292 ms
42,224 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 2 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 1 ms
4,348 KB
testcase_07 AC 1 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 1 ms
4,348 KB
testcase_11 AC 2 ms
4,348 KB
testcase_12 AC 2 ms
4,348 KB
testcase_13 AC 384 ms
41,236 KB
testcase_14 AC 385 ms
41,500 KB
testcase_15 AC 390 ms
42,224 KB
testcase_16 AC 390 ms
42,224 KB
testcase_17 AC 384 ms
42,224 KB
testcase_18 AC 387 ms
42,224 KB
testcase_19 AC 392 ms
42,224 KB
testcase_20 AC 392 ms
42,224 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

#define rep(i,a,b) for(int i=a;i<b;i++)
#define MP make_pair

typedef pair<string, int> psi;

int main()
{
	int H, W, N;
	cin >> H >> W >> N;
	vector<psi> SK(N);
	rep(i, 0, N) {
		string s;
		int k;
		cin >> s >> k;
		SK[i] = MP(s, k);
	}

	int x, y;
	x = y = 0;
	rep(i, 0, N)
	{
		int j = N - 1 - i;

		string s = SK[j].first;
		int k = SK[j].second;

		if (s == "R")
		{
			if (y == k)
			{
				x--;
				if (x < 0) x = W - 1;
			}
		}
		else
		{
			if (x == k)
			{
				y--;
				if (y < 0) y = H - 1;
			}
		}
	}

	if ((x + y) % 2 == 0)
		cout << "white" << endl;
	else
		cout << "black" << endl;
}
0