結果
| 問題 |
No.2521 Don't be Same
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-10-28 01:14:00 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 59 ms / 2,000 ms |
| コード長 | 1,952 bytes |
| コンパイル時間 | 2,850 ms |
| コンパイル使用メモリ | 182,544 KB |
| 最終ジャッジ日時 | 2025-02-17 16:28:18 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 27 |
ソースコード
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#include <fstream>
#include <chrono>
#include <random>
#include <bitset>
#include <atcoder/all>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) ((int)(x).size())
#define pb push_back
using ll = long long;
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
int win(ll a, ll b){
if(a==0 && b==0) return 0;
if(abs(a-b)==1 && max(a,b)%2==0) return 0;
return 1;
}
int main(){
ll X,Y; cin >> X >> Y;
if(win(X,Y)) cout << "First" << endl;
else{
cout << "Second" << endl;
char op;
cin >> op;
if(op=='C' || op=='D') return 0;
if(op=='B'){
X=0;Y=0;
}
else{
int i; ll x; cin >> i >> x;
if(i==1) X-=x;
else Y-=x;
}
}
while(X+Y>0){
if(X==Y){
cout << 'B' << endl;
X=0; Y=0;
}
else{
if(X==0){
cout << "A 2 " << Y << endl;
Y -= Y;
}
else if(Y==0){
cout << "A 1 " << X << endl;
X -= X;
}
else{
if(X>Y){
ll x = (Y%2==0)?Y-1:Y+1;
cout << "A 1 " << X-x << endl;
X -= X-x;
}
else{
ll y = (X%2==0)?X-1:X+1;
cout << "A 2 " << Y-y << endl;
Y -= Y-y;
}
}
}
char op;
cin >> op;
if(op=='C' || op=='D') break;
if(op=='B'){
X=0;Y=0;
}
else{
int i; ll x; cin >> i >> x;
if(i==1) X-=x;
else Y-=x;
}
}
return 0;
}