結果

問題 No.351 市松スライドパズル
ユーザー nksk38
提出日時 2017-07-08 11:30:26
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 320 ms / 2,000 ms
コード長 712 bytes
コンパイル時間 657 ms
コンパイル使用メモリ 73,616 KB
実行使用メモリ 8,320 KB
最終ジャッジ日時 2024-10-06 19:39:09
合計ジャッジ時間 4,846 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 17
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<queue>
#include<vector>
#include<functional>
#include<cmath>
#include<map>
#include<stack>
#include<set>
#include<numeric>

using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;

char s[1000010];
int k[1000010];

int main()
{
	ll H,W,N;
	cin >> H >> W >> N;

	for (int i = 0; i < N; i++)
		cin >> s[i] >> k[i];
	
	int r = 0, c = 0;
	for (int i =N-1; i >= 0; i--) {
		if (s[i] == 'R' && k[i] == r) {
			c = (c + W - 1) % W;
		}else if(s[i] == 'C' && k[i] == c){
			r = (r + H - 1) % H;
		}
	}
	if ((r + c) % 2 == 0)
		cout << "white" << endl;
	else
		cout << "black" << endl;
	
	return 0;
}
0