結果
問題 | No.513 宝探し2 |
ユーザー |
![]() |
提出日時 | 2024-09-30 01:02:31 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,829 bytes |
コンパイル時間 | 1,388 ms |
コンパイル使用メモリ | 111,792 KB |
実行使用メモリ | 25,604 KB |
平均クエリ数 | 67.00 |
最終ジャッジ日時 | 2024-09-30 01:02:35 |
合計ジャッジ時間 | 3,119 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 6 WA * 6 |
コンパイルメッセージ
main.cpp: In function 'int main()': main.cpp:84:20: warning: 'use' may be used uninitialized [-Wmaybe-uninitialized] 84 | ll d2 = ask(x,m2); | ~~~^~~~~~ main.cpp:61:8: note: 'use' was declared here 61 | ll use; | ^~~
ソースコード
#include<iostream>#include<vector>#include<algorithm>using namespace std;using ll = long long;#include<map>#include<cassert>int c;map<pair<ll,ll>,ll> memo;ll nx = 10;ll ny = 10;ll ask(ll x,ll y){// ll d = abs(x-nx) + abs(y-ny);// if(d==0) {// cout<<c<<endl;// exit(0);// }if(memo.find({x,y})!=memo.end()) return memo[{x,y}];c++;if(c>100){assert(false);}cout<<x<<" "<<y<<endl;ll d;cin>>d;if(d==0){exit(0);}return memo[{x,y}] = d;}int main(){cin.tie(nullptr);ios::sync_with_stdio(false);ll left = 0;ll right = 100000;int cnt = 0;ll n1,n2;while(right-left>2){//cout<<left<<" "<<right<<endl;ll m1 = (21*left+13*right) / 34;ll m2 = (21*right+13*left) / 34;// if(cnt==1) m1 = n1;// if(cnt==2) m2 = n2;n1 = m1;n2 = m2;ll d1 = ask(m1,0);ll d2 = ask(m2,0);if(d1<=d2) {right = m2;cnt = 1;}else{left = m1;cnt = 2;}}ll use;ll mn = 1e9;for(ll x = left;x<=right;x++){ll d = ask(x,0);if(d<mn){mn = d;use = x;}}ll x = use;left = 0;right = 100000;cnt = 0;n1,n2;while(right-left>2){ll m1 = (21*left+13*right) / 34;ll m2 = (21*right+13*left) / 34;// if(cnt==1) m1 = n1;// if(cnt==2) m2 = n2;n1 = m1;n2 = m2;ll d1 = ask(x,m1);ll d2 = ask(x,m2);if(d1<=d2){right = m2;cnt = 1;}else{left = m1;cnt = 2;}}for(ll y = left;y<=right;y++){ll d = ask(x,y);}}