結果
| 問題 |
No.2521 Don't be Same
|
| コンテスト | |
| ユーザー |
ゆにぽけ
|
| 提出日時 | 2023-10-27 23:45:15 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 2,551 bytes |
| コンパイル時間 | 935 ms |
| コンパイル使用メモリ | 124,720 KB |
| 最終ジャッジ日時 | 2025-02-17 16:12:53 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | TLE * 1 |
| other | -- * 27 |
ソースコード
#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;
}
}
}
ゆにぽけ