結果

問題 No.594 壊れた宝物発見機
ユーザー uafr_csuafr_cs
提出日時 2017-11-10 23:08:06
言語 Java21
(openjdk 21)
結果
AC  
実行時間 320 ms / 2,000 ms
コード長 1,582 bytes
コンパイル時間 4,771 ms
コンパイル使用メモリ 77,176 KB
実行使用メモリ 74,364 KB
平均クエリ数 86.00
最終ジャッジ日時 2023-09-23 14:50:46
合計ジャッジ時間 10,159 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 320 ms
71,312 KB
testcase_01 AC 316 ms
72,648 KB
testcase_02 AC 298 ms
72,848 KB
testcase_03 AC 289 ms
72,348 KB
testcase_04 AC 296 ms
74,364 KB
testcase_05 AC 299 ms
73,204 KB
testcase_06 AC 289 ms
73,112 KB
testcase_07 AC 292 ms
73,512 KB
testcase_08 AC 298 ms
72,868 KB
testcase_09 AC 304 ms
72,852 KB
testcase_10 AC 293 ms
71,708 KB
testcase_11 AC 294 ms
72,712 KB
testcase_12 AC 288 ms
72,736 KB
testcase_13 AC 307 ms
72,692 KB
testcase_14 AC 293 ms
72,584 KB
testcase_15 AC 287 ms
72,896 KB
testcase_16 AC 291 ms
72,804 KB
testcase_17 AC 286 ms
72,528 KB
testcase_18 AC 289 ms
72,988 KB
testcase_19 AC 289 ms
71,524 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.math.BigInteger;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.Scanner;

public class Main {
	
	public static long MOD = 1000000007;
	
	public static void query(int x, int y, int z){
		System.out.println("?" + " " + x + " " + y + " " + z);
	}
	
	public static void query(int id, int v){
		switch (id) {
		case 0: query(v, 0, 0); break;
		case 1: query(0, v, 0); break;
		case 2: query(0, 0, v); break;
		}
	}
	
	public static int search(int id, int upper, int lower, Scanner sc){
		while(lower + 2 < upper){
			//System.out.println(lower + " " + upper);
			final int uul = (upper * 2 + lower) / 3;
			final int ull = (upper + lower * 2) / 3;
			
			query(id, uul);
			final long uul_value = sc.nextLong();
			
			query(id, ull);
			final long ull_value = sc.nextLong();
			
			if(uul_value < ull_value){
				lower = ull;
			}else{
				upper = uul;
			}
		}
		
		query(id, upper);
		final long upper_value = sc.nextLong();
		
		query(id, lower + 1);
		final long middle_value = sc.nextLong();
		
		query(id, lower);
		final long lower_value = sc.nextLong();
		
		final long min = Math.min(middle_value, Math.min(lower_value, upper_value));
		if(middle_value == min){
			return lower + 1;
		}else if(lower_value == min){
			return lower;
		}else{
			return upper;
		}
	}
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		final int x = search(0, 150, -150, sc);
		final int y = search(1, 150, -150, sc);
		final int z = search(2, 150, -150, sc);
		
		System.out.println("!" + " " + x + " " + y + " " + z);
	}
}
0