結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 213 ms
72,744 KB
testcase_03 WA -
testcase_04 AC 198 ms
72,240 KB
testcase_05 RE -
testcase_06 RE -
testcase_07 WA -
testcase_08 RE -
testcase_09 RE -
testcase_10 AC 197 ms
73,088 KB
testcase_11 AC 207 ms
72,816 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