結果
問題 | No.3018 目隠し宝探し |
ユーザー |
![]() |
提出日時 | 2025-01-25 16:31:20 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 79 ms / 2,000 ms |
コード長 | 1,455 bytes |
コンパイル時間 | 3,009 ms |
コンパイル使用メモリ | 274,312 KB |
実行使用メモリ | 25,984 KB |
平均クエリ数 | 2.68 |
最終ジャッジ日時 | 2025-01-25 23:53:29 |
合計ジャッジ時間 | 6,187 ms |
ジャッジサーバーID (参考情報) |
judge6 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 21 |
ソースコード
#include <bits/stdc++.h>using namespace std;using ll = long long;#ifdef LOCAL#include <debug.hpp>#else#define debug(...)#endifint main() {cin.tie(nullptr);ios::sync_with_stdio(false);cout << fixed << setprecision(20);int H, W;cin >> H >> W;if (H == 1 && W == 1) {cout << "! " << H << " " << W << endl;} else if (H == 1) {cout << "? " << 1 << " " << 1 << endl;int d;cin >> d;for (int w = 1; w <= W; w++) {if ((w - 1) * (w - 1) == d) {cout << "! " << 1 << " " << w << endl;return 0;}}} else if (W == 1) {cout << "? " << 1 << " " << 1 << endl;int d;cin >> d;for (int h = 1; h <= H; h++) {if ((h - 1) * (h - 1) == d) {cout << "! " << h << " " << 1 << endl;return 0;}}} else {cout << "? " << 1 << " " << 1 << endl;int d1;cin >> d1;cout << "? " << 1 << " " << W << endl;int d2;cin >> d2;for (int h = 1; h <= H; h++) {for (int w = 1; w <= W; w++) {if ((h - 1) * (h - 1) + (w - 1) * (w - 1) != d1) continue;if ((h - 1) * (h - 1) + (W - w) * (W - w) != d2) continue;cout << "! " << h << " " << w << endl;return 0;}}}}