結果
| 問題 | 
                            No.2521 Don't be Same
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2023-10-27 22:25:24 | 
| 言語 | C++14  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 70 ms / 2,000 ms | 
| コード長 | 1,605 bytes | 
| コンパイル時間 | 835 ms | 
| コンパイル使用メモリ | 74,444 KB | 
| 実行使用メモリ | 25,580 KB | 
| 平均クエリ数 | 9.32 | 
| 最終ジャッジ日時 | 2024-09-25 14:28:19 | 
| 合計ジャッジ時間 | 4,641 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge4 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 1 | 
| other | AC * 27 | 
ソースコード
#include<iostream>
#include<set>
#include<cassert>
using namespace std;
int G[100][100];
void calcG()
{
	G[0][0]=0;
	for(int a=0;a<100;a++)for(int b=0;b<100;b++)
	{
		if(a==0&&b==0)continue;
		set<int>S;
		if(a==b)S.insert(G[0][0]);
		for(int i=1;i<=a;i++)S.insert(G[a-i][b]);
		for(int i=1;i<=b;i++)S.insert(G[a][b-i]);
		int g=0;
		while(S.find(g)!=S.end())g++;
		G[a][b]=g;
	}
	for(int a=0;a<10;a++)
	{
		for(int b=0;b<10;b++)cout<<G[a][b]<<"\t";
		cout<<endl;
	}
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int X,Y;
	cin>>X>>Y;
	if(abs(X-Y)==1&&min(X,Y)%2==1)
	{
		cout<<"Second"<<endl;
		char c;
		cin>>c;
		if(c=='C')return 0;
		assert(c=='A');
		int i,x;
		cin>>i>>x;
		if(i==1)X-=x;
		else Y-=x;
	}
	else cout<<"First"<<endl;
	while(true)
	{
		assert(!(X==0&&Y==0));
		if(X==Y)
		{
			cout<<"B"<<endl;
			X=Y=0;
		}
		else if(X==0)
		{
			cout<<"A 2 "<<Y<<endl;
			Y=0;
		}
		else if(Y==0)
		{
			cout<<"A 1 "<<X<<endl;
			X=0;
		}
		else
		{
			if(X+1<Y)
			{
				if(X%2==1)
				{
					cout<<"A 2 "<<Y-X-1<<endl;
					Y=X+1;
				}
				else
				{
					cout<<"A 2 "<<Y-X+1<<endl;
					Y=X-1;
				}
			}
			else if(Y+1<X)
			{
				if(Y%2==1)
				{
					cout<<"A 1 "<<X-Y-1<<endl;
					X=Y+1;
				}
				else
				{
					cout<<"A 1 "<<X-Y+1<<endl;
					X=Y-1;
				}
			}
			else if(X+1==Y)
			{
				assert(X%2==0);
				cout<<"A 2 2"<<endl;
				Y-=2;
			}
			else if(Y+1==X)
			{
				assert(Y%2==0);
				cout<<"A 1 2"<<endl;
				X-=2;
			}
			else assert(false);
		}
		char c;int i,x;
		cin>>c;
		if(c=='C')return 0;
		assert(c=='A');
		cin>>i>>x;
		if(i==1)X-=x;
		else Y-=x;
	}
}