結果
問題 | No.2521 Don't be Same |
ユーザー | FplusFplusF |
提出日時 | 2023-10-27 23:14:17 |
言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 66 ms / 2,000 ms |
コード長 | 3,301 bytes |
コンパイル時間 | 2,051 ms |
コンパイル使用メモリ | 202,436 KB |
実行使用メモリ | 25,220 KB |
平均クエリ数 | 9.57 |
最終ジャッジ日時 | 2024-09-25 15:12:31 |
合計ジャッジ時間 | 5,491 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 27 |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll=long long; using pll=pair<ll,ll>; using tll=tuple<ll,ll,ll>; using ld=long double; const ll INF=(1ll<<60); #define rep(i,n) for(ll i=0;i<(ll)(n);i++) #define all(v) v.begin(),v.end() template<class T> void chmin(T &a,T b){ if(a>b){ a=b; } } template<class T> void chmax(T &a,T b){ if(a<b){ a=b; } } int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); ll x,y; cin >> x >> y; if(abs(x-y)==1&&max(x,y)%2==0){ cout << "Second\n"; cout.flush(); while(true){ char c; cin >> c; if(c=='C'||c=='D') return 0; if(c=='A'){ ll i,j; cin >> i >> j; if(i==1) x-=j; if(i==2) y-=j; } if(c=='B'){ x=0; y=0; } if(x==y){ x=0; y=0; cout << "B\n"; cout.flush(); }else{ ll i=-1,j=-1; if(x==0){ i=2; j=y; }else if(y==0){ i=1; j=x; }else if(x<y){ if(x%2==0){ i=2; j=y-(x-1); }else{ i=2; j=y-(x+1); } }else{ if(y%2==0){ i=1; j=x-(y-1); }else{ i=1; j=x-(y+1); } } if(i==1) x-=j; if(i==2) y-=j; cout << "A " << i << ' ' << j << '\n'; cout.flush(); } } }else{ cout << "First\n"; cout.flush(); while(true){ if(x==y){ x=0; y=0; cout << "B\n"; cout.flush(); }else{ ll i=-1,j=-1; if(x==0){ i=2; j=y; }else if(y==0){ i=1; j=x; }else if(x<y){ if(x%2==0){ i=2; j=y-(x-1); }else{ i=2; j=y-(x+1); } }else{ if(y%2==0){ i=1; j=x-(y-1); }else{ i=1; j=x-(y+1); } } if(i==1) x-=j; if(i==2) y-=j; cout << "A " << i << ' ' << j << '\n'; cout.flush(); } char c; cin >> c; if(c=='C'||c=='D') return 0; if(c=='A'){ ll i,j; cin >> i >> j; if(i==1) x-=j; if(i==2) y-=j; } if(c=='B'){ x=0; y=0; } } } }