結果
問題 | No.2252 Find Zero |
ユーザー | tenten |
提出日時 | 2023-08-09 11:23:27 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 245 ms / 2,000 ms |
コード長 | 1,991 bytes |
コンパイル時間 | 4,084 ms |
コンパイル使用メモリ | 84,172 KB |
実行使用メモリ | 70,328 KB |
平均クエリ数 | 78.17 |
最終ジャッジ日時 | 2024-04-27 05:39:40 |
合計ジャッジ時間 | 8,510 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 178 ms
69,348 KB |
testcase_01 | AC | 245 ms
70,328 KB |
testcase_02 | AC | 148 ms
69,604 KB |
testcase_03 | AC | 197 ms
70,096 KB |
testcase_04 | AC | 153 ms
69,456 KB |
testcase_05 | AC | 145 ms
69,744 KB |
testcase_06 | AC | 151 ms
69,424 KB |
testcase_07 | AC | 147 ms
69,336 KB |
testcase_08 | AC | 185 ms
69,996 KB |
testcase_09 | AC | 209 ms
69,944 KB |
testcase_10 | AC | 150 ms
69,684 KB |
testcase_11 | AC | 147 ms
69,700 KB |
testcase_12 | AC | 146 ms
69,428 KB |
testcase_13 | AC | 148 ms
70,048 KB |
testcase_14 | AC | 144 ms
69,880 KB |
testcase_15 | AC | 146 ms
69,500 KB |
testcase_16 | AC | 146 ms
69,628 KB |
testcase_17 | AC | 147 ms
69,480 KB |
ソースコード
import java.io.*; import java.util.*; import java.util.stream.*; public class Main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(); int n = sc.nextInt(); for (int i = 0; i < n - 1; i += 2) { System.out.println("? " + i + " " + (i + 1)); System.out.flush(); int x = sc.nextInt(); if (x == i) { System.out.println("! " + (i + 1)); System.out.flush(); return; } else if (x == i + 1) { System.out.println("! " + i); System.out.flush(); return; } } System.out.println("! " + (n - 1)); System.out.flush(); } } class Utilities { static String arrayToLineString(Object[] arr) { return Arrays.stream(arr).map(x -> x.toString()).collect(Collectors.joining("\n")); } static String arrayToLineString(int[] arr) { return String.join("\n", Arrays.stream(arr).mapToObj(String::valueOf).toArray(String[]::new)); } } class Scanner { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(""); StringBuilder sb = new StringBuilder(); public Scanner() throws Exception { } public int nextInt() throws Exception { return Integer.parseInt(next()); } public long nextLong() throws Exception { return Long.parseLong(next()); } public double nextDouble() throws Exception { return Double.parseDouble(next()); } public int[] nextIntArray() throws Exception { return Stream.of(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray(); } public String next() throws Exception { while (!st.hasMoreTokens()) { st = new StringTokenizer(br.readLine()); } return st.nextToken(); } }