結果
| 問題 |
No.3018 目隠し宝探し
|
| コンテスト | |
| ユーザー |
Jikky1618
|
| 提出日時 | 2025-01-25 14:54:15 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,515 bytes |
| コンパイル時間 | 3,154 ms |
| コンパイル使用メモリ | 276,736 KB |
| 実行使用メモリ | 26,228 KB |
| 平均クエリ数 | 2.68 |
| 最終ジャッジ日時 | 2025-01-25 23:32:07 |
| 合計ジャッジ時間 | 6,123 ms |
|
ジャッジサーバーID (参考情報) |
judge6 / judge10 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 1 |
| other | WA * 21 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#ifdef LOCAL
#include <debug.hpp>
#else
#define debug(...)
#endif
// 離散関数 f: Z -> R の区間 [left, right] での黄金分割探索
template <class T, class F>
auto golden_section_search(ll left, ll right, F&& f, bool maximize = true) {
ll a = left - 1, x, b;
{
ll s = 1, t = 2;
while (t < right - left + 2) swap(s += t, t);
x = a + t - s, b = a + t;
}
T fx = f(x);
while (a + b != 2 * x) {
ll y = a + b - x;
T fy = f(y);
if (right < y || maximize ? fx < fy : fx > fy) {
a = x, x = y, fx = fy;
} else {
b = a, a = y;
}
}
return make_pair(x, fx);
}
int main() {
cin.tie(nullptr);
ios::sync_with_stdio(false);
cout << fixed << setprecision(20);
int H, W;
cin >> H >> W;
// H を特定
// int local_ans_h = 17, local_ans_w = 334;
auto check = [&](int h, int w) -> int {
cout << "? " << h << " " << w << endl;
// int d = (local_ans_h - h) * (local_ans_h - h) + (local_ans_w - w) * (local_ans_w - w);
int d;
cin >> d;
if (d == -1) exit(0);
return d;
};
auto f1 = [&](int h) -> int { return check(h, 1); };
auto [h, d1] = golden_section_search<int>(1, H, f1, false);
auto f2 = [&](int w) -> int { return check(h, w); };
auto [w, d2] = golden_section_search<int>(1, W, f2, false);
cout << "! " << h << " " << w << endl;
}
Jikky1618