結果

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

ソースコード

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