結果

問題 No.3018 目隠し宝探し
ユーザー eve__fuyuki
提出日時 2025-02-02 14:48:08
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 98 ms / 2,000 ms
コード長 839 bytes
コンパイル時間 2,727 ms
コンパイル使用メモリ 192,168 KB
実行使用メモリ 25,984 KB
平均クエリ数 2.68
最終ジャッジ日時 2025-02-02 14:48:15
合計ジャッジ時間 6,837 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

void fast_io() {
	ios::sync_with_stdio(false);
	std::cin.tie(nullptr);
}

int main() {
	fast_io();
	int h, w;
	cin >> h >> w;
	if (h == 1 && w == 1) {
		cout << "! 1 1" << endl;
		return 0;
	}
	if (h == 1 || w == 1) {
		cout << "? 1 1" << endl;
		int d;
		cin >> d;
		int e = sqrt(d) + 1;
		if (h == 1) {
			cout << "! 1 " << e << endl;
		} else {
			cout << "! " << e << " 1" << endl;
		}
		return 0;
	}
	cout << "? 1 1" << endl;
	int d1;
	cin >> d1;
	cout << "? 1 " << w << endl;
	int d2;
	cin >> d2;
	for (int i = 1; i <= h; i++) {
		for (int j = 1; j <= w; j++) {
			int d1_true = (i - 1) * (i - 1) + (j - 1) * (j - 1);
			int d2_true = (i - 1) * (i - 1) + (w - j) * (w - j);
			if (d1_true == d1 && d2_true == d2) {
				cout << "! " << i << " " << j << endl;
				return 0;
			}
		}
	}
}
0