結果
問題 |
No.2521 Don't be Same
|
ユーザー |
|
提出日時 | 2025-03-07 15:09:58 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 79 ms / 2,000 ms |
コード長 | 1,608 bytes |
コンパイル時間 | 2,206 ms |
コンパイル使用メモリ | 195,144 KB |
実行使用メモリ | 25,984 KB |
平均クエリ数 | 9.71 |
最終ジャッジ日時 | 2025-03-07 15:10:05 |
合計ジャッジ時間 | 6,364 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 27 |
ソースコード
#include "bits/stdc++.h" using namespace std; #define REP(i, n) for (int i = 0; i < n; i++) #define REPR(i, n) for (int i = n; i >= 0; i--) #define FOR(i, m, n) for (ll i = m; i < n; i++) #define FORR(i, m, n) for (ll i = m; i >= n; i--) #define REPO(i, n) for (ll i = 1; i <= n; i++) #define ll long long #define INF (ll)1ll << 60 #define MINF (-1 * INF) #define ALL(n) n.begin(), n.end() #define MOD (ll)1000000007 #define P pair<ll, ll> P next(ll x, ll y){ if(x == y and x > 0) return P(0, 0); if(x + 1 == y and y % 2 == 0) return P(-1, -1); if(y + 1 == x and x % 2 == 0) return P(-1, -1); if(x < y){ if(x == 0) return P(2, y); else if(x % 2 == 1) return P(2, y - (x + 1)); else return P(2, y - (x - 1)); } if(x > y){ if(y == 0) return P(1, x); else if(y % 2 == 1) return P(1, x - (y + 1)); else return P(1, x - (y - 1)); } return P(-1, -1); } int main(){ ll x, y; cin >> x >> y; P jd = next(x, y); if(jd == P(-1, -1)){ cout << "Second" << endl; char c; ll a, b; cin >> c >> a >> b; if(a == 1)x -= b; else y -= b; } else cout << "First" << endl; while(1){ P ne = next(x, y); if(ne == P(0, 0)){ x = y = 0; cout << 'B' << endl; } else if(ne.first == 1){ x -= ne.second; cout <<"A 1 " << ne.second << endl; } else { y -= ne.second; cout << "A 2 " << ne.second << endl; } char c; ll a, b; cin >> c; if(c == 'C' or c == 'D')break; else if(c == 'B') x = y = 0; else { cin >> a >> b; if(a == 1)x -= b; else y -= b; } } }