結果

問題 No.2521 Don't be Same
ユーザー pointNpointN
提出日時 2023-10-28 01:06:48
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,888 bytes
コンパイル時間 3,286 ms
コンパイル使用メモリ 190,844 KB
実行使用メモリ 94,704 KB
平均クエリ数 0.07
最終ジャッジ日時 2023-10-28 01:06:56
合計ジャッジ時間 7,222 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 67 ms
24,660 KB
testcase_01 TLE -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#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(1){
    if(X==Y){
      cout << 'B' << endl;
    }
    else{
      if(X==0){
        cout << "A 2 " << Y << endl;
      }
      else if(Y==0){
        cout << "A 1 " << X << endl;
      }
      else{
        if(X>Y){
          ll x = (Y%2==0)?Y-1:Y+1;
          cout << "A 1 " << X-x << endl;
        }
        else{
          ll y = (X%2==0)?X-1:X+1;
          cout << "A 2 " << Y-y << endl;
        }
      }
    }

    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;
    }
    if(X==0 && Y==0) break;
  }
  return 0;
}
0