結果

問題 No.513 宝探し2
ユーザー takeya_okinotakeya_okino
提出日時 2019-08-05 21:55:33
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,053 bytes
コンパイル時間 2,193 ms
コンパイル使用メモリ 75,892 KB
実行使用メモリ 73,836 KB
平均クエリ数 51.08
最終ジャッジ日時 2023-09-23 17:59:11
合計ジャッジ時間 6,612 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 207 ms
72,836 KB
testcase_03 WA -
testcase_04 AC 217 ms
72,316 KB
testcase_05 RE -
testcase_06 RE -
testcase_07 WA -
testcase_08 RE -
testcase_09 RE -
testcase_10 AC 209 ms
72,508 KB
testcase_11 AC 203 ms
72,508 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int l = 0;
    int r = 100001;
    int ans1 = 0;
    while(l < r) {
      System.out.println(l + " " + 0);
      System.out.flush();
      int ret1 = sc.nextInt();
      int med = (l + r) / 2;
      System.out.println(med + " " + 0);
      System.out.flush();
      int ret2 = sc.nextInt();
      if(ret2 == (ret1 + l - med)) {
        ans1 = med;
        l = med + 1;
      } else {
        r = med;
      }
    }
    l = 0;
    r = 100001;
    int ans2 = 0;
    while(l < r) {
      System.out.println(ans1 + " " + l);
      System.out.flush();
      int ret1 = sc.nextInt();
      int med = (l + r) / 2;
      System.out.println(ans1 + " " + med);
      System.out.flush();
      int ret2 = sc.nextInt();
      if(ret2 == (ret1 + l - med)) {
        ans2 = med;
        l = med + 1;
      } else {
        r = med;
      }
    }
    System.out.println(ans1 + " " + ans2);
    System.out.flush();
    System.exit(0);
  }
}
0