結果
| 問題 |
No.2521 Don't be Same
|
| コンテスト | |
| ユーザー |
milanis48663220
|
| 提出日時 | 2023-10-27 23:23:15 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 62 ms / 2,000 ms |
| コード長 | 3,433 bytes |
| コンパイル時間 | 1,066 ms |
| コンパイル使用メモリ | 117,248 KB |
| 最終ジャッジ日時 | 2025-02-17 16:01:26 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 27 |
ソースコード
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <cmath>
#include <numeric>
#include <functional>
#include <cassert>
#define debug_value(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << #x << "=" << x << endl;
#define debug(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << x << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;
typedef long long ll;
template<typename T>
vector<vector<T>> vec2d(int n, int m, T v){
return vector<vector<T>>(n, vector<T>(m, v));
}
template<typename T>
vector<vector<vector<T>>> vec3d(int n, int m, int k, T v){
return vector<vector<vector<T>>>(n, vector<vector<T>>(m, vector<T>(k, v)));
}
template<typename T>
void print_vector(vector<T> v, char delimiter=' '){
if(v.empty()) {
cout << endl;
return;
}
for(int i = 0; i+1 < v.size(); i++) cout << v[i] << delimiter;
cout << v.back() << endl;
}
bool solve(int x, int y){
static bool seen[1000][1000];
static bool win[1000][1000];
if(seen[x][y]) return win[x][y];
if(x == y) return true;
if(x == 0 || y == 0) return true;
bool ans = false;
for(int xx = 0; xx < x && !ans; xx++){
if(!solve(xx, y)) {
ans = true;
}
}
for(int yy = 0; yy < y && !ans; yy++){
if(!solve(x, yy)) {
ans = true;
}
}
seen[x][y] = true;
win[x][y] = ans;
return ans;
}
void test(){
for(int x = 1; x <= 100; x++){
for(int y = 1; y <= 100; y++){
if(!solve(x, y)) cout << "lose:" << x << ' ' << y << endl;
}
}
cout << "Done" << endl;
}
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
cout << setprecision(10) << fixed;
vector<int> v(2);
for(int i = 0; i < 2; i++) cin >> v[i];
auto do_next = [&](){
if(v[0] == v[1]){
cout << "B" << endl;
return;
}
if(v[0] == 0){
cout << "A " << 2 << ' ' << v[1] << endl;
return;
}
if(v[1] == 0){
cout << "A " << 1 << ' ' << v[0] << endl;
return;
}
int small_idx = v[0] < v[1] ? 0 : 1;
int large_idx = small_idx^1;
if(v[small_idx]%2 == 1){
cout << "A " << large_idx+1 << ' ' << v[large_idx]-v[small_idx]-1 << endl;
v[large_idx] = v[small_idx]+1;
}else{
cout << "A " << large_idx+1 << ' ' << v[large_idx]-v[small_idx]+1 << endl;
v[large_idx] = v[small_idx]-1;
}
};
auto do_opponent = [&](){
string s; cin >> s;
if(s == "A"){
int i, x; cin >> i >> x; i--;
v[i] -= x;
}else if(s == "B"){
v[0] = 0;
v[1] = 0;
}else{
exit(0);
}
};
bool first = true;
if(abs(v[0]-v[1]) == 1){
int mn = min(v[0], v[1]);
if(mn%2 == 1){
first = false;
}
}
if(first) cout << "First" << endl;
else{
cout << "Second" << endl;
do_opponent();
}
while(true){
do_next();
do_opponent();
// cout << "v:"; print_vector(v);
}
}
milanis48663220