結果

問題 No.3018 目隠し宝探し
ユーザー 👑 Nachia
提出日時 2025-01-25 12:55:35
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 1,295 bytes
コンパイル時間 518 ms
コンパイル使用メモリ 72,692 KB
実行使用メモリ 26,228 KB
平均クエリ数 2.68
最終ジャッジ日時 2025-01-25 22:26:45
合計ジャッジ時間 3,361 ms
ジャッジサーバーID
(参考情報)
judge2 / judge8
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 17 WA * 4
権限があれば一括ダウンロードができます

ソースコード

diff #
プレゼンテーションモードにする

#ifdef NACHIA
#define _GLIBCXX_DEBUG
#else
#define NDEBUG
#endif
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using i64 = long long;
using u64 = unsigned long long;
#define rep(i,n) for(int i=0; i<int(n); i++)
const i64 INF = 1001001001001001001;
template<typename A> void chmin(A& l, const A& r){ if(r < l) l = r; }
template<typename A> void chmax(A& l, const A& r){ if(l < r) l = r; }
using namespace std;
int ask(int u, int v){
cout << "? " << u << " " << v << "\n";
cout.flush();
int x; cin >> x;
if(x < 0) exit(0);
return x;
}
int isqrt(int x){
int y = 0;
while((y+1)*(y+1) <= x) x++;
return y;
}
void ans(int u, int v){
cout << "! " << u << " " << v << "\n";
cout.flush();
exit(0);
}
void testcase(){
int H, W; cin >> H >> W;
if(H == 1 && W == 1) ans(1, 1);
if(H == 1) ans(1, isqrt(ask(1,1))+1);
if(W == 1) ans(isqrt(ask(1,1))+1, 1);
int a = ask(1,1);
int b = ask(H,1);
for(int y=1; y<=H; y++) for(int x=1; x<=W; x++){
int dx = x - 1, dy = y - 1;
if(dx*dx + dy*dy != a) continue;
dy = y - H;
if(dx*dx + dy*dy != b) continue;
ans(y,x);
}
}
int main(){
ios::sync_with_stdio(false); cin.tie(nullptr);
testcase();
return 0;
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0