結果

問題 No.3018 目隠し宝探し
ユーザー さかさのさかな
提出日時 2025-01-25 14:39:11
言語 Java
(openjdk 23)
結果
WA  
実行時間 -
コード長 1,034 bytes
コンパイル時間 5,516 ms
コンパイル使用メモリ 88,524 KB
実行使用メモリ 60,404 KB
平均クエリ数 2.23
最終ジャッジ日時 2025-01-25 23:25:41
合計ジャッジ時間 9,310 ms
ジャッジサーバーID
(参考情報)
judge5 / judge9
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 1
other AC * 8 WA * 13
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		int w = sc.nextInt();
		if(h * w == 1) {
			System.out.println("! 1 1");
			return;
		}if(h == 1) {
			System.out.println("? " + 1 + " " + 1);
			int p1 = sc.nextInt();
			System.out.println("! " + 1 + " " + (1 + (int)Math.sqrt(p1)));
			return;
		}if(w == 1) {
			System.out.println("? " + 1 + " " + 1);
			int p1 = sc.nextInt();
			System.out.println("! " + (1 + (int)Math.sqrt(p1)) + " " + 1);
			return;
		}
		System.out.println("? " + 1 + " " + 1);
		int p1 = sc.nextInt();
		System.out.println("? " + 1 + " " + h);
		int p2 = sc.nextInt();
		for(int i = 1;i <= h;i++) {
			for(int j = 1;j <= w;j++) {
				int sub1 = (1 - i) * (1 - i) + (1 - j) * (1 - j);
				int sub2 = (h - i) * (h - i) + (1 - j) * (1 - j);
				if(sub1 == p1 && sub2 == p2) {
					System.out.println("! " + i + " " + j);
					return;
				}
			}
		}
	}

}
0