結果
問題 | No.3018 目隠し宝探し |
ユーザー |
![]() |
提出日時 | 2025-01-25 13:31:47 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 85 ms / 2,000 ms |
コード長 | 1,604 bytes |
コンパイル時間 | 2,622 ms |
コンパイル使用メモリ | 88,400 KB |
実行使用メモリ | 26,052 KB |
平均クエリ数 | 2.68 |
最終ジャッジ日時 | 2025-01-25 22:49:41 |
合計ジャッジ時間 | 4,117 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge8 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 21 |
ソースコード
#include <iostream> #include <iomanip>//小数点出力用 //cout << fixed << setprecision(10) << ans; #include <cmath> #include <algorithm> #include <vector> #include <queue> #include <stack> #include <set> #include <map> using ll = long long; using namespace std; #define modP 998244353 bool chkrng0idx(int pos, int sup) { return (0 <= pos && pos < sup); } int clk4(int num) { return (num - 2) * (num % 2); } void yn(bool tf) { cout << (tf ? "Yes\n" : "No\n"); } int squareRoot(long long x) { int left = 0; int right = 1000001; int mid; while (right - left > 1) { mid = (right + left) / 2; if ((long long)mid * (long long)mid <= x) { left = mid; } else { right = mid; } } return left; } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int H;cin >> H; int W;cin >> W; if (H == 1 && W == 1) { cout << "! 1 1" << endl;return 0; } cout << "? 1 1" << endl; int d1;cin >> d1; if (min(H, W) == 1) { if (H == 1) { cout << "! 1 " << squareRoot(d1) + 1 << endl; } else { cout << "! " << squareRoot(d1) + 1 << " 1" << endl; } return 0; } cout << "? 1 " << W << endl; int d2;cin >> d2; for (int i = 1;i <= H;i++) { for (int j = 1;j <= W;j++) { if ((i - 1) * (i - 1) + (j - 1) * (j - 1) == d1 && (i - 1) * (i - 1) + (j - W) * (j - W) == d2) { cout << "! " << i << " " << j << endl; return 0; } } } return 0; }