結果
問題 |
No.2521 Don't be Same
|
ユーザー |
![]() |
提出日時 | 2023-10-27 22:07:44 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 63 ms / 2,000 ms |
コード長 | 2,228 bytes |
コンパイル時間 | 1,854 ms |
コンパイル使用メモリ | 195,996 KB |
最終ジャッジ日時 | 2025-02-17 15:05:47 |
ジャッジサーバーID (参考情報) |
judge5 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 27 |
ソースコード
#include <bits/stdc++.h> using namespace std; typedef long long ll; template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; } template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; } #define all(x) (x).begin(),(x).end() #define fi first #define se second #define mp make_pair #define si(x) int(x.size()) const int mod=998244353,MAX=300005,INF=1<<30; bool solve(int a,int b){ if(a==0&&b==0) return false; if(a==0||b==0) return true; if(a==b) return true; if(a){ for(int k=1;k<=a;k++){ if(!solve(a-k,b)) return true; } } if(b){ for(int k=1;k<=b;k++){ if(!solve(a,b-k)) return true; } } return false; } int main(){ for(int a=0;a<=10;a++){ for(int b=0;b<=10;b++){ //cout<<solve(a,b)<<" "; } //cout<<endl; } int X,Y;cin>>X>>Y; auto mov=[&](){ if(X==Y) cout<<"B"<<endl; else if(X==0){ cout<<"A"<<" "<<2<<" "<<Y<<endl; Y=0; } else if(Y==0){ cout<<"A"<<" "<<1<<" "<<X<<endl; X=0; } else{ if(Y%2==0&&X>Y-1){ cout<<"A"<<" "<<1<<" "<<X-(Y-1)<<endl; X=Y-1; } else if(Y%2==1&&X>Y+1){ cout<<"A"<<" "<<1<<" "<<X-(Y+1)<<endl; X=Y+1; } else if(X%2==0&&Y>X-1){ cout<<"A"<<" "<<2<<" "<<Y-(X-1)<<endl; Y=X-1; } else if(X%2==1&&Y>X+1){ cout<<"A"<<" "<<2<<" "<<Y-(X+1)<<endl; Y=X+1; } else exit(1); } }; auto wait=[&](){ char c;cin>>c; if(c=='C') exit(0); if(c=='D') exit(1); if(c=='A'){ ll a,b;cin>>a>>b; if(a==1) X-=b; else Y-=b; }else{ X=0; Y=0; } }; if((X+1==Y&&Y%2==0)||(Y+1==X&&X%2==0)){ cout<<"Second"<<endl; wait(); }else{ cout<<"First"<<endl; } while(1){ mov(); wait(); } }