結果

問題 No.2521 Don't be Same
コンテスト
ユーザー tnakao0123
提出日時 2024-06-19 22:55:07
言語 C++17
(gcc 15.3.0 + boost 1.92.0 + ACL)
コンパイル:
g++-15 -O2 -fplugin=/usr/lib/yukicoder/noavx512-gcc15.so -lm -std=c++17 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 513 ms / 2,000 ms
+ 999µs
コード長 1,238 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 215 ms
コンパイル使用メモリ 56,424 KB
実行使用メモリ 7,728 KB
平均クエリ数 9.93
最終ジャッジ日時 2026-11-05 01:01:02
合計ジャッジ時間 3,983 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 28
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

/* -*- coding: utf-8 -*-
 *
 * 2521.cc:  No.2521 Don't be Same - yukicoder
 */

#include<cstdio>
#include<algorithm>
 
using namespace std;

/* subroutines */

int read(int &i, int &z) {
  char op[4];
  scanf("%s", op);

  i = z = -1;
  if (op[0] == 'A') scanf("%d%d", &i, &z), i--;
  return op[0] - 'A';
}

/* main */

int main() {
  int x, y;
  scanf("%d%d", &x, &y);

  if (((x & 1) && y == x + 1) || ((y & 1) && x == y + 1)) {
    puts("Second"); fflush(stdout);

    int i, z;
    int r = read(i, z);
    if (r >= 2) return 0;
    if (i == 0) x -= z;
    else y -= z;
  }
  else {
    puts("First"); fflush(stdout);
  }

  while (x > 0 || y > 0) {
    if (x == y) {
      puts("B");
      x = y = 0;
    }
    else if (x == 0) {
      printf("A 2 %d\n", y);
      y = 0;
    }
    else if (y == 0) {
      printf("A 1 %d\n", x);
      x = 0;
    }
    else if (x < y) {
      int z = (x & 1) ? y - (x + 1) : y - (x - 1);
      printf("A 2 %d\n", z);
      y -= z;
    }
    else { // x > y
      int z = (y & 1) ? x - (y + 1) : x - (y - 1);
      printf("A 1 %d\n", z);
      x -= z;
    }
    fflush(stdout);

    int i, z;
    int r = read(i, z);

    if (r >= 2) break;
    if (i == 0) x -= z;
    else y -= z;
  }

  return 0;
}
0