結果
問題 |
No.513 宝探し2
|
ユーザー |
![]() |
提出日時 | 2019-06-13 15:17:39 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 25 ms / 2,000 ms |
コード長 | 1,449 bytes |
コンパイル時間 | 1,596 ms |
コンパイル使用メモリ | 167,304 KB |
実行使用メモリ | 25,476 KB |
平均クエリ数 | 29.08 |
最終ジャッジ日時 | 2024-07-17 02:16:35 |
合計ジャッジ時間 | 2,681 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 12 |
ソースコード
#include<bits/stdc++.h> using namespace std; using ll = long long; #define FOR(i,a,b) for(ll i=(a);i<(b);++i) #define ALL(v) (v).begin(), (v).end() #define p(s) cout<<(s)<<endl #define p2(s, t) cout << (s) << " " << (t) << endl #define br() p("") #define pn(s) cout << (#s) << " " << (s) << endl const ll mod = 1e9 + 7; const ll inf = 1e18; ll query(ll x, ll y){ p2(x, y); ll d; cin >> d; if(d==0) exit(0); return d; } int main(){ cin.tie(0); ios::sync_with_stdio(false); ll left = -1; ll left_d = query(left, 0); ll right = 100000+1; ll right_d = query(right, 0); // X while(left+1!=right){ ll center = (left+right)/2; ll d = query(center, 0); ll assumed_center_d = left_d - (center-left); if(assumed_center_d==d){ left = center; left_d = d; }else{ right = center; right_d = d; } } ll center_x = left; // Y left = -1; left_d = query(center_x, left); right = 100000+1; right_d = query(center_x, right); while(left+1!=right){ ll center = (left+right)/2; ll d = query(center_x, center); ll assumed_center_d = left_d - (center-left); if(assumed_center_d==d){ left = center; left_d = d; }else{ right = center; right_d = d; } } return 0; }