結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 201 ms
72,204 KB
testcase_03 WA -
testcase_04 AC 200 ms
70,848 KB
testcase_05 RE -
testcase_06 RE -
testcase_07 WA -
testcase_08 RE -
testcase_09 RE -
testcase_10 AC 203 ms
73,216 KB
testcase_11 AC 201 ms
73,080 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();
  }
}
0