結果
| 問題 |
No.2521 Don't be Same
|
| コンテスト | |
| ユーザー |
shobonvip
|
| 提出日時 | 2023-10-27 23:21:18 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 119 ms / 2,000 ms |
| コード長 | 2,209 bytes |
| コンパイル時間 | 3,944 ms |
| コンパイル使用メモリ | 250,732 KB |
| 最終ジャッジ日時 | 2025-02-17 16:00:40 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 27 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
//* ATCODER
#include<atcoder/all>
using namespace atcoder;
typedef modint998244353 mint;
//*/
/* BOOST MULTIPRECISION
#include<boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
//*/
typedef long long ll;
#define rep(i, s, n) for (int i = (int)(s); i < (int)(n); i++)
#define rrep(i, s, n) for (int i = (int)(n)-1; i >= (int)(s); i--)
template <typename T> bool chmin(T &a, const T &b) {
if (a <= b) return false;
a = b;
return true;
}
template <typename T> bool chmax(T &a, const T &b) {
if (a >= b) return false;
a = b;
return true;
}
template <typename T> T max(vector<T> &a){
assert(!a.empty());
T ret = a[0];
for (int i=0; i<(int)a.size(); i++) chmax(ret, a[i]);
return ret;
}
template <typename T> T min(vector<T> &a){
assert(!a.empty());
T ret = a[0];
for (int i=0; i<(int)a.size(); i++) chmin(ret, a[i]);
return ret;
}
template <typename T> T sum(vector<T> &a){
T ret = 0;
for (int i=0; i<(int)a.size(); i++) ret += a[i];
return ret;
}
int main(){
int x, y; cin >> x >> y;
int now = 0;
if (x % 2 == 0 && y % 2 == 1){
if (x - 1 == y){
now = 1;
}
}
if (x % 2 == 1 && y % 2 == 0){
if (y - 1 == x){
now = 1;
}
}
if (now == 0){
cout << "First" << endl;
}else{
cout << "Second" << endl;
}
auto lft = [&](int x, int y){
if (y % 2 == 0){
return y - 1;
}else{
return y + 1;
}
};
auto rgt = [&](int x, int y){
return lft(y, x);
};
while(true){
if (now == 0){
if (x == y){
cout << "B" << endl;
x = 0;
y = 0;
}else if(x == 0){
cout << "A 2 " << y << endl;
y = 0;
}else if(y == 0){
cout << "A 1 " << x << endl;
x = 0;
}else{
int v = lft(x, y);
int w = rgt(x, y);
if (v < x){
cout << "A 1 " << x - v << endl;
x -= x - v;
}else{
assert(w < y);
cout << "A 2 " << y - w << endl;
y -= y - w;
}
}
}else{
char c; cin >> c;
assert(c != 'D');
if (c == 'C'){
break;
}
if (c == 'A'){
int k; cin >> k;
int r; cin >> r;
if (k == 1){
x -= r;
}else{
assert(k == 2);
y -= r;
}
}else{
x = 0;
y = 0;
}
}
now ^= 1;
}
}
shobonvip