結果

問題 No.3598 Queen vs. King
コンテスト
ユーザー tnakao0123
提出日時 2026-07-25 17:22:24
言語 C++17
(gcc 15.2.0 + boost 1.90.0)
コンパイル:
g++-15 -O2 -lm -std=c++17 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 58 ms / 2,000 ms
+ 0µs
コード長 879 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 157 ms
コンパイル使用メモリ 52,480 KB
実行使用メモリ 6,016 KB
平均クエリ数 2131.33
最終ジャッジ日時 2026-07-25 17:22:29
合計ジャッジ時間 1,705 ms
ジャッジサーバーID
(参考情報)
judge3_1 / judge2_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 10
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

/* -*- coding: utf-8 -*-
 *
 * 3598.cc:  No.3598 Queen vs. King - yukicoder
 */

#include<cstdio>
#include<cstdlib>
#include<algorithm>

using namespace std;

/* constant */

const int MAX_H = 100;
const int MAX_W = 100;

/* typedef */

/* global variables */

/* subroutines */

bool bob(int &kx, int &ky) {
  scanf("%d%d", &kx, &ky);
  if (kx < 0) exit(0);
  return kx == 0 && ky == 0;
}

void alice(int qx, int qy) {
  printf("%d %d\n", qx, qy); fflush(stdout);
}

/* main */

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

  while (tn--) {
    int h, w;
    scanf("%d%d", &h, &w);

    int qx = 1, qy = 1, kx = h, ky = w;

    bob(kx, ky);

    if (kx > 2) {
      qx = kx - 1;
      alice(qx, qy);
      if (bob(kx, ky)) continue;
    }

    qy = ky;
    alice(qx, qy);
    if (bob(kx, ky)) continue;

    qx++, qy = ky;
    alice(qx, qy);
    bob(kx, ky);
  }

  return 0;
}

0