結果

問題 No.2521 Don't be Same
ユーザー ゆにぽけゆにぽけ
提出日時 2023-10-27 23:45:15
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 2,551 bytes
コンパイル時間 1,281 ms
コンパイル使用メモリ 129,216 KB
実行使用メモリ 98,220 KB
最終ジャッジ日時 2023-10-27 23:45:24
合計ジャッジ時間 8,175 ms
ジャッジサーバーID
(参考情報)
judge10 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 -- -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<vector>
#include<algorithm>
#include<cstring>
#include<cassert>
#include<cmath>
#include<ctime>
#include<iomanip>
#include<numeric>
#include<stack>
#include<queue>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<bitset>
#include<random>
#include<functional>
#include<utility>
using namespace std;
void solve();
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int tt = 1;
	//cin >> tt;
	while(tt--) solve();
}
int dp[100][100];
int dfs(int x,int y)
{
	if(!x && !y) return 0;
	if(x == y) return dp[x][y] = 1;
	if(dp[x][y] >= 0) return dp[x][y];

	for(int i = 1;i <= x;i++) if(!dfs(x-i,y)) return dp[x][y] = 1;
	for(int i = 1;i <= y;i++) if(!dfs(x,y-i)) return dp[x][y] = 1;
	return dp[x][y] = 0;
}
void solve()
{
	/*for(int i = 0;i < 100;i++)for(int j = 0;j < 100;j++) dp[i][j] = -1;
	for(int i = 0;i < 10;i++)for(int j = 0;j < 10;j++)
	{
		cout << "(" << i << "," << j << ") -> " << (dfs(i,j) ? "First":"Second") << "\n";
	}*/
	int X,Y;
	cin >> X >> Y;
	bool s = false;
	if(X > Y) swap(X,Y),s = true;
	bool f = true;
	if(X+1 == Y && X%2 == 1) cout << "Second" << endl,f = false;
	else cout << "First" << endl;
	cout << flush;
	while(true)
	{
		if(f)
		{
			if(X == Y) cout << 'B' << endl;
			else
			{
				char c = 'A';
				int p,q;
				cout << 'A' << " ";
				if(!X) p = s ? 1:2,q = Y;
				else if(!Y) p = s ? 2:1,q = X;
				else
				{
					if(X > Y)
					{
						p = s ? 2:1;
						if(Y & 1) q = X-Y-1,X = Y+1;
						else q = X-Y+1,X = Y-1;
					}
					else
					{
						p = s ? 1:2;
						if(X & 1) q = Y-X-1,Y = X+1;
						else q = Y-X+1,Y = X-1;
					}
				}
				cout << c << " " << p << " " << q << endl;
			}
			cout << flush;
			char c;
			cin >> c;
			if(c == 'C') return;
			assert(c != 'B');
			{
				int p,q;
				cin >> p >> q;
				if(s) p = 3-p;
				if(p == 1) X -= q;
				else Y -= q;
			}
		}
		else
		{
			char c;
			cin >> c;
			if(c == 'C') return;
			assert(c != 'B');
			{
				int p,q;
				cin >> p >> q;
				if(s) p = 3-p;
				if(p == 1) X -= q;
				else Y -= q;
			}
			if(X == Y) cout << 'B' << endl;
			else
			{
				c = 'A';
				int p,q;
				cout << 'A' << " ";
				if(!X) p = s ? 1:2,q = Y;
				else if(!Y) p = s ? 2:1,q = X;
				else
				{
					if(X > Y)
					{
						p = s ? 2:1;
						if(Y & 1) q = X-Y-1,X = Y+1;
						else q = X-Y+1,X = Y-1;
					}
					else
					{
						p = s ? 1:2;
						if(X & 1) q = Y-X-1,Y = X+1;
						else q = Y-X+1,Y = X-1;
					}
				}
				cout << c << " " << p << " " << q << endl;
			}
			cout << flush;
		}
	}
}
0