結果
問題 | No.3018 目隠し宝探し |
ユーザー |
![]() |
提出日時 | 2025-01-25 15:09:07 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 1,394 bytes |
コンパイル時間 | 3,296 ms |
コンパイル使用メモリ | 277,276 KB |
実行使用メモリ | 26,216 KB |
平均クエリ数 | 1.00 |
最終ジャッジ日時 | 2025-01-25 23:41:42 |
合計ジャッジ時間 | 8,335 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | RE * 1 |
other | WA * 2 RE * 19 |
ソースコード
#include <bits/stdc++.h>using namespace std;using ll = long long;#ifdef LOCAL#include <debug.hpp>#else#define debug(...)#endif// N は平方数, 0 <= N <= 4.5*10^18 < 2^62ll integer_sqrt(ll N) {// √N < 2^31ll low = -1, high = 1LL << 31;while (high - low > 1) {ll mid = (low + high) / 2, mid2 = mid * mid;if (mid2 <= N) {low = mid;} else {high = mid;}}return low;}int main() {cin.tie(nullptr);ios::sync_with_stdio(false);cout << fixed << setprecision(20);int H, W;cin >> H >> W;// int local_h = 114, local_w = 514;vector<int> res(W + 1, -1);auto check = [&](int h) -> int {if (res[h] != -1) return res[h];cout << h << " " << 1 << endl;// int d = (local_h - h) * (local_h - h) + (local_w - 1) * (local_w - 1);int d;cin >> d;if (d == -1) assert(false);return res[h] = d;};int left = 0, right = H + 1;// 三分探索while (right - left > 2) {int m1 = left + (right - left) / 3;int m2 = right - (right - left) / 3;if (check(m1) > check(m2)) {left = m1;} else {right = m2;}}int h = left + 1, d = check(left + 1);int w = integer_sqrt(d) + 1;cout << "! " << h << " " << w << endl;}