結果

問題 No.3018 目隠し宝探し
ユーザー yuutyann
提出日時 2025-01-25 14:02:51
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 80 ms / 2,000 ms
コード長 1,016 bytes
コンパイル時間 3,410 ms
コンパイル使用メモリ 275,440 KB
実行使用メモリ 26,228 KB
平均クエリ数 2.68
最終ジャッジ日時 2025-01-25 23:05:57
合計ジャッジ時間 6,450 ms
ジャッジサーバーID
(参考情報)
judge10 / judge9
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main() {
    int h = 0,w = 0;
    cin >> h >> w;
    if (h == 1 && w == 1) {
        cout << "! 1 1" << endl;
    } else if (h == 1) {
        cout << "? 1 1" << endl;
        int temp = 0;
        cin >> temp;
        cout << "! 1 " << 1 + round(sqrt(temp)) << endl;
    } else if (w == 1) {
        cout << "? 1 1" << endl;
        int temp = 0;
        cin >> temp;
        cout << "! " << 1 + round(sqrt(temp)) << " 1" << endl;
    } else {
        cout << "? 1 1" << endl;
        cout << "? 1 2" << endl;
        int temp1 = 0,temp2 = 0;
        cin >> temp1 >> temp2;
        for (int i = 1;i <= h;i++) {
            for (int j = 1;j <= w;j++) {
                if ((i - 1) * (i - 1) + (j - 1) * (j - 1) == temp1) {
                    if ((i - 1) * (i - 1) + (j - 2) * (j - 2) == temp2) {
                        cout << "! " << i << " " << j << endl;
                        return 0;
                    }
                }
            }
        }
    }
}
0