結果
| 問題 |
No.2521 Don't be Same
|
| コンテスト | |
| ユーザー |
ゆにぽけ
|
| 提出日時 | 2023-10-27 23:33:05 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 2,631 bytes |
| コンパイル時間 | 1,164 ms |
| コンパイル使用メモリ | 127,000 KB |
| 最終ジャッジ日時 | 2025-02-17 16:06:27 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 23 TLE * 1 -- * 3 |
ソースコード
#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
{
cout << 'A' << " ";
if(!X) cout << (s ? 1:2) << " " << Y << endl;
else if(!Y) cout << (s ? 1:2) << " " << X << endl;
else
{
if(X > Y)
{
cout << (s ? 2:1) << " ";
if(Y & 1) cout << X-Y-1 << endl,X = Y+1;
else cout << X-Y+1 << endl,X = Y-1;
}
else
{
cout << (s ? 1:2) << " ";
if(X & 1) cout << Y-X-1 << endl,Y = X+1;
else cout << Y-X+1 << endl,Y = X-1;
}
}
}
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
{
cout << 'A' << " ";
if(!X) cout << (s ? 1:2) << " " << Y << endl;
else if(!Y) cout << (s ? 1:2) << " " << X << endl;
else
{
if(X > Y)
{
cout << (s ? 2:1) << " ";
if(Y & 1) cout << X-Y-1 << endl,X = Y+1;
else cout << X-Y+1 << endl,X = Y-1;
}
else
{
cout << (s ? 1:2) << " ";
if(X & 1) cout << Y-X-1 << endl,Y = X+1;
else cout << Y-X+1 << endl,Y = X-1;
}
}
}
cout.flush();
}
}
}
ゆにぽけ