結果

問題 No.1187 皇帝ペンギン
ユーザー uwiuwi
提出日時 2020-08-22 13:47:42
言語 Java21
(openjdk 21)
結果
AC  
実行時間 173 ms / 1,000 ms
コード長 1,052 bytes
コンパイル時間 5,715 ms
コンパイル使用メモリ 76,336 KB
実行使用メモリ 72,056 KB
平均クエリ数 20.96
最終ジャッジ日時 2023-09-24 05:57:26
合計ジャッジ時間 16,045 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 157 ms
69,648 KB
testcase_01 AC 152 ms
69,056 KB
testcase_02 AC 166 ms
71,788 KB
testcase_03 AC 158 ms
69,004 KB
testcase_04 AC 161 ms
69,696 KB
testcase_05 AC 170 ms
72,056 KB
testcase_06 AC 153 ms
70,952 KB
testcase_07 AC 152 ms
69,240 KB
testcase_08 AC 157 ms
69,676 KB
testcase_09 AC 156 ms
70,612 KB
testcase_10 AC 170 ms
71,588 KB
testcase_11 AC 162 ms
71,112 KB
testcase_12 AC 164 ms
71,424 KB
testcase_13 AC 161 ms
71,148 KB
testcase_14 AC 160 ms
70,752 KB
testcase_15 AC 154 ms
69,512 KB
testcase_16 AC 157 ms
70,624 KB
testcase_17 AC 159 ms
71,036 KB
testcase_18 AC 173 ms
71,660 KB
testcase_19 AC 158 ms
70,696 KB
testcase_20 AC 158 ms
71,316 KB
testcase_21 AC 157 ms
70,900 KB
testcase_22 AC 158 ms
71,144 KB
testcase_23 AC 158 ms
71,192 KB
testcase_24 AC 156 ms
70,544 KB
testcase_25 AC 167 ms
70,860 KB
testcase_26 AC 157 ms
71,284 KB
testcase_27 AC 162 ms
69,536 KB
testcase_28 AC 161 ms
70,932 KB
testcase_29 AC 150 ms
69,884 KB
testcase_30 AC 151 ms
70,860 KB
testcase_31 AC 151 ms
69,408 KB
testcase_32 AC 170 ms
72,004 KB
testcase_33 AC 155 ms
68,324 KB
testcase_34 AC 153 ms
69,684 KB
testcase_35 AC 153 ms
70,484 KB
testcase_36 AC 168 ms
71,776 KB
testcase_37 AC 152 ms
69,348 KB
testcase_38 AC 153 ms
67,860 KB
testcase_39 AC 167 ms
70,820 KB
testcase_40 AC 155 ms
71,044 KB
testcase_41 AC 157 ms
71,116 KB
testcase_42 AC 151 ms
69,708 KB
testcase_43 AC 158 ms
69,704 KB
testcase_44 AC 155 ms
70,880 KB
testcase_45 AC 152 ms
69,916 KB
testcase_46 AC 153 ms
69,932 KB
testcase_47 AC 154 ms
68,984 KB
testcase_48 AC 161 ms
69,872 KB
testcase_49 AC 162 ms
70,536 KB
testcase_50 AC 163 ms
71,324 KB
testcase_51 AC 159 ms
70,584 KB
testcase_52 AC 172 ms
71,648 KB
testcase_53 AC 158 ms
69,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package gioku2020day1;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

public class F2 {
	static Scanner in;
	static PrintWriter out;
	static String INPUT = "";
	
	static boolean get(int x)
	{
		out.println("? " + x);
		out.flush();
		return in.next().equals("safe");
	}
	
	static void solve()
	{
		int low = 0, high = 1000;
		while(high - low > 1){
			int h = high+low>>1;
			boolean r1 = get(h);
			boolean r2 = get(h+1);
			if(!r1 && !r2){
				high = h;
			}else{
				low = h;
			}
		}
		out.println("! " + (high-1));
		out.flush();
	}

	
	public static void main(String[] args) throws Exception
	{
		in = INPUT.isEmpty() ? new Scanner(System.in) : new Scanner(INPUT);
		out = new PrintWriter(System.out);
		
		solve();
		out.flush();
	}
	
	static int ni() { return Integer.parseInt(in.next()); }
	static long nl() { return Long.parseLong(in.next()); }
	static double nd() { return Double.parseDouble(in.next()); }
	static void tr(Object... o) { if(INPUT.length() != 0)System.out.println(Arrays.deepToString(o)); }
}
0