Submission #487407

#TimeUsernameProblemLanguageResultExecution timeMemory
487407FatihSolakWorm Worries (BOI18_worm)C++17
32 / 100
1 ms296 KiB
#include <bits/stdc++.h> #define N 200005 using namespace std; map<vector<int>,int> mp; int n,m,k,q; int ask(int x,int y,int z){ if(x < 1 || x > n)return 0; if(mp[{x,y,z}])return mp[{x,y,z}]; cout << "? " << x << " " << y << " " << z << endl; int ret; cin >> ret; return mp[{x,y,z}] = ret; } void ans(int x,int y,int z){ cout << "! " << x << " " << y << " " << z << endl; exit(0); } const double golden_ratio = (sqrt(5) - 1)/2; void solve(){ cin >> n >> m >> k >> q; if(m == 1 && k == 1){ int l = 1,r = n; int x = golden_ratio * l + (1-golden_ratio)*r; int y = golden_ratio * r + (1-golden_ratio)*l; while(l + 5< r){ if(x >= y){ break; } if(ask(x,1,1) >= ask(y,1,1)){ r = y - 1; y = x; x = golden_ratio * l + (1-golden_ratio)*r; } else{ l = x + 1; x = y; y = golden_ratio * r + (1-golden_ratio)*l; } } for(int i=l;i<=r;i++){ if(ask(i,1,1) >= ask(i-1,1,1) && ask(i,1,1) >= ask(i+1,1,1)){ ans(i,1,1); } } } } int32_t main(){ int t=1; //cin>>t; while(t--){ solve(); } #ifdef Local cout<<endl<<fixed<<setprecision(2)<<1000.0 * clock() / CLOCKS_PER_SEC<< " milliseconds "; #endif }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...