結果
| 問題 |
No.3018 目隠し宝探し
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-01-25 14:50:19 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 1,565 bytes |
| コンパイル時間 | 3,657 ms |
| コンパイル使用メモリ | 281,640 KB |
| 実行使用メモリ | 28,628 KB |
| 平均クエリ数 | 2.68 |
| 最終ジャッジ日時 | 2025-01-25 23:30:44 |
| 合計ジャッジ時間 | 7,361 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 20 RE * 1 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#ifdef local
#include <debug.hpp>
#else
#define debug(...)
#endif
#define rep(i, n) for (int i = 0; i < n; i++)
template <class T> istream& operator>>(istream& I, vector<T>& V) {for (T& X : V) I >> X; return I;}
template <class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
template <class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
vector<int> di = {-1, 1, 0, 0}, dj = {0, 0, -1, 1}; int inf = 2e9; long INF = 1e18;
int main() {
int h, w;
cin >> h >> w;
vector<pair<int, int>> c;
rep(i, h) rep(j, w) c.emplace_back(i + 1, j + 1);
int qi = 1, qj = 1;
while (true) {
cout << "? " << qi << " " << qj << endl;
int d;
cin >> d;
if (d == -1) {
auto [i, j] = c[0];
cout << "! " << i << " " << j << endl;
}
vector<pair<int, int>> nc;
for (auto [i, j] : c) {
if ((qi - i) * (qi - i) + (qj - j) * (qj - j) == d) {
nc.emplace_back(i, j);
}
}
if (nc.size() == 1) {
auto [i, j] = nc[0];
cout << "! " << i << " " << j << endl;
break;
} else {
if (qi == 1 and qj == 1) qi = h;
else if (qi == h and qj == 1) qj = w;
else if (qi == h and qj == w) qi = 1;
else {
qi = rand() % h + 1;
qj = rand() % w + 1;
}
}
swap(c, nc);
}
return 0;
}