結果

問題 No.351 市松スライドパズル
ユーザー CELICACELICA
提出日時 2020-10-20 21:35:04
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 210 ms / 2,000 ms
コード長 697 bytes
コンパイル時間 1,995 ms
コンパイル使用メモリ 171,132 KB
実行使用メモリ 44,116 KB
最終ジャッジ日時 2023-09-28 13:50:12
合計ジャッジ時間 7,377 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 189 ms
44,056 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 1 ms
4,384 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 204 ms
43,332 KB
testcase_14 AC 205 ms
43,260 KB
testcase_15 AC 210 ms
44,008 KB
testcase_16 AC 208 ms
44,044 KB
testcase_17 AC 203 ms
44,116 KB
testcase_18 AC 202 ms
44,052 KB
testcase_19 AC 207 ms
44,108 KB
testcase_20 AC 209 ms
44,052 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using ul = unsigned long;
using ull = unsigned long long;

const string TARGET_NO = "0351";

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);

	ll h, w, n;
	cin >> h >> w >> n;

	stack<pair<string, ll> > st;
	for (ll i = 0; i < n; ++i)
	{
		string s;
		ll k;
		cin >> s >> k;
		st.push(make_pair(s, k));
	}

	ll c{ 0 }, r{ 0 };
	while (!st.empty())
	{
		pair<string, ll> p = st.top();
		st.pop();
		if (p.first == "R" && p.second == r)
			c = (c + w - 1) % w;
		else if (p.first == "C" && p.second == c)
			r = (r + h - 1) % h;
	}

	string res = (r + c) & 1 ? "black" : "white";
	cout << res << "\n";

	return 0;
}
0