結果
| 問題 |
No.3018 目隠し宝探し
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-02-01 19:47:13 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 1,490 bytes |
| コンパイル時間 | 6,169 ms |
| コンパイル使用メモリ | 276,872 KB |
| 実行使用メモリ | 51,432 KB |
| 平均クエリ数 | 2.59 |
| 最終ジャッジ日時 | 2025-02-01 19:47:28 |
| 合計ジャッジ時間 | 7,943 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 16 RE * 5 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int ask(int i, int j) {
cout << "? " << i << " " << j << endl;
int d;
cin >> d;
assert(d != -1);
return d;
}
void ans(int i, int j) {
cout << "! " << i << " " << j << endl;
exit(0);
}
int dist(int x, int y) { return x * x + y * y; }
int main() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
int H, W;
cin >> H >> W;
int d1 = ask(1, 1);
if(d1 == 0) ans(1, 1);
bool f = false;
for(int i = 1; i <= H; i++) for(int j = 1; j <= W; j++) {
if((i != 1 || j != 1) && dist(i - 1, j - 1) == d1) {
f = true;
int d2 = ask(i, j);
if(d2 == 0) ans(i, j);
vector<pair<int, int>> ss;
for(int ii = 1; ii <= H; ii++) for(int jj = 1; jj <= W; jj++) {
if(dist(ii - 1, jj - 1) == d1 && dist(ii - i, jj - j) == d2) {
ss.push_back({ii, jj});
}
}
assert(!ss.empty());
if((int)ss.size() == 1) {
ans(ss.front().first, ss.front().second);
} else if((int)ss.size() == 2){
if(!ask(ss.front().first, ss.front().second)) {
ans(ss.front().first, ss.front().second);
} else {
ans(ss.back().first, ss.back().second);
}
} else {
assert(0);
}
}
}
if(!f) {
ans(H, W);
}
}