結果

問題 No.351 市松スライドパズル
ユーザー imulanimulan
提出日時 2016-03-11 23:19:47
言語 C++11
(gcc 13.3.0)
結果
AC  
実行時間 134 ms / 2,000 ms
コード長 670 bytes
コンパイル時間 1,268 ms
コンパイル使用メモリ 162,396 KB
実行使用メモリ 11,140 KB
最終ジャッジ日時 2024-09-25 02:36:56
合計ジャッジ時間 3,816 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 17
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:22:23: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   22 |         rep(i,n) scanf(" %c %d",&v[i].fi,&v[i].sc);
      |                  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~

ソースコード

diff #

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

typedef long long ll;
#define rep(i,n) for(i=0;i<n;++i)
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define mp make_pair
#define pb push_back
#define fi first
#define sc second

typedef pair<char,int> p;

int main()
{
	int i;

	int h,w,n;
	cin >>h >>w >>n;

	vector<p> v(n);
	rep(i,n) scanf(" %c %d",&v[i].fi,&v[i].sc);

	int x=0,y=0;
	for(i=n-1; i>=0; --i)
	{
		char s=v[i].fi;
		int k=v[i].sc;

		if(s=='R' && k==x) y=(y+w-1)%w;
		else if(s=='C' && k==y) x=(x+h-1)%h;

		//printf(" %d %d\n",x,y);
	}

	string ans="white";
	if((x+y)%2==1) ans="black";
	std::cout << ans << std::endl;
}
0