結果

問題 No.351 市松スライドパズル
ユーザー kapokapo
提出日時 2016-05-16 01:52:59
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 768 ms / 2,000 ms
コード長 1,033 bytes
コンパイル時間 743 ms
コンパイル使用メモリ 72,212 KB
実行使用メモリ 402,360 KB
最終ジャッジ日時 2023-10-25 07:45:58
合計ジャッジ時間 8,116 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 225 ms
11,528 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 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 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 1 ms
4,348 KB
testcase_13 AC 768 ms
402,152 KB
testcase_14 AC 694 ms
402,200 KB
testcase_15 AC 681 ms
402,360 KB
testcase_16 AC 687 ms
402,360 KB
testcase_17 AC 681 ms
402,360 KB
testcase_18 AC 681 ms
402,360 KB
testcase_19 AC 683 ms
402,360 KB
testcase_20 AC 687 ms
402,360 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <stack>
#include <utility>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define pb push_back

void row_r(vector<int> &v, int w)
{
	rep(i, 0, w) v[i] ? v[i] = 0 : v[i] = 1;
}

int main(void)
{
	int i, j, h, w, n, k;
	char s;
	cin >> h >> w >> n;

	vector<vector<int> > vv;
	vector<int> v = { 1 };
	rep(i, 1, w) v[i - 1] ? v.pb(0) : v.pb(1);
	vv.pb(v);
	rep(i, 1, h) { row_r(v, w); vv.pb(v); }

	stack<pair<char, int> > st;
	pair<char, int> pa;
	pair<int, int> pos;
	pos.first = 0; pos.second = 0;

	rep(i, 0, n) {
		cin >> s >> k;
		pa.first = s;  // h
		pa.second = k; // w
		st.push(pa);
	}
	rep(i, 0, n) {
		pa = st.top();
		st.pop();

		if (pa.first == 'C' && pa.second == pos.second) {
			if (pos.first == 0) pos.first = h-1;
			else pos.first--;
		}
		else if (pa.first == 'R' && pa.second == pos.first) {
			if (pos.second == 0) pos.second = w-1;
			else pos.second--;
		}
	}

	(vv[ pos.first ][ pos.second ]) ? printf("white\n") : printf("black\n");

	return 0;
}
0