結果

問題 No.513 宝探し2
ユーザー uafr_csuafr_cs
提出日時 2017-05-05 23:19:25
言語 Java21
(openjdk 21)
結果
RE  
実行時間 -
コード長 2,643 bytes
コンパイル時間 2,561 ms
コンパイル使用メモリ 78,400 KB
実行使用メモリ 73,648 KB
平均クエリ数 74.42
最終ジャッジ日時 2023-09-23 13:47:13
合計ジャッジ時間 6,895 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 173 ms
73,296 KB
testcase_01 AC 203 ms
72,540 KB
testcase_02 RE -
testcase_03 AC 193 ms
72,564 KB
testcase_04 RE -
testcase_05 AC 187 ms
72,404 KB
testcase_06 RE -
testcase_07 RE -
testcase_08 AC 169 ms
73,040 KB
testcase_09 AC 189 ms
71,516 KB
testcase_10 RE -
testcase_11 AC 185 ms
72,860 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
	
	public static int RANGE = 100;
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int y = 0, x = 0;
		System.out.println(x + " " + y);
		int min_dist = sc.nextInt();
		if(min_dist == 0){ return; }
		
		
		{
			int add = 1;
			while(true){
				if(add == 1){
					final int next_plus_x = x + add;
					final int next_minus_x = x - add;
					final int next_y = y;
					
					System.out.println(next_plus_x + " " + next_y);
					final int next_plus_dist = sc.nextInt();
					if(next_plus_dist == 0){ return; }
					
					System.out.println(next_minus_x + " " + next_y);
					final int next_minus_dist = sc.nextInt();
					if(next_minus_dist == 0){ return; }
					
					if(min_dist < Math.min(next_plus_dist, next_minus_dist)){ break; }
					
					if(next_plus_dist < next_minus_dist){
						x = next_plus_x;
						add = 2;
						min_dist = next_plus_dist;
					}else{
						x = next_minus_x;
						add = -2;
						min_dist = next_minus_dist;
					}
				}else{
					final int next_x = x + add;
					final int next_y = y;
					
					System.out.println(next_x + " " + next_y);
					final int next_dist = sc.nextInt();
					if(next_dist == 0){ return; }
					
					if(next_dist < min_dist){
						x = next_x;
						add *= 2;
						min_dist = next_dist;
					}else{
						add = 1;
					}
				}
			}
		}
		
		{
			int add = 1;
			while(true){
				if(add == 1){
					final int next_x = x;
					final int next_plus_y = y + add;
					final int next_minus_y = y - add;
					
					System.out.println(next_x + " " + next_plus_y);
					final int next_plus_dist = sc.nextInt();
					if(next_plus_dist == 0){ return; }
					
					System.out.println(next_x + " " + next_minus_y);
					final int next_minus_dist = sc.nextInt();
					if(next_minus_dist == 0){ return; }
					
					if(min_dist < Math.min(next_plus_dist, next_minus_dist)){ break; }
					
					if(next_plus_dist < next_minus_dist){
						y = next_plus_y;
						add = 2;
						min_dist = next_plus_dist;
					}else{
						y = next_minus_y;
						add = -2;
						min_dist = next_minus_dist;
					}
				}else{
					final int next_x = x;
					final int next_y = y + add;
					
					System.out.println(next_x + " " + next_y);
					final int next_dist = sc.nextInt();
					if(next_dist == 0){ return; }
					
					if(next_dist < min_dist){
						y = next_y;
						add *= 2;
						min_dist = next_dist;
					}else{
						add = 1;
					}
				}
			}
		}
	}
}
0