Submission #723626

#TimeUsernameProblemLanguageResultExecution timeMemory
723626Erkinoff_MohammedWorm Worries (BOI18_worm)C++14
0 / 100
1382 ms9652 KiB
#include "bits/stdc++.h" using namespace std; #define INF 2000000000 #define INFLL 3000000000000000000LL #define ll long long int main() { //cin.tie(0)->sync_with_stdio(0); int n,m,k,q; cin>>n>>m>>k>>q; map<pair<int,pair<int,int>>,int>mp; bool b=1; int x=1; int y=1; int z=1; cout<<"? 1 1 1"<<"\n"; q--; int h; cin>>h; while(q&&b){ b=0; int x_1=mp[{x-1,{y,z}}]; int x_2=mp[{x+1,{y,z}}]; int y_1=mp[{x,{y-1,z}}]; int y_2=mp[{x,{y+1,z}}]; int z_1=mp[{x,{y,z-1}}]; int z_2=mp[{x,{y,z+1}}]; if(x_1==0&&x>1&&q){ q--; cout<<"? "<<x-1<<" "<<y<<" "<<z<<"\n"; cin>>x_1; mp[{x-1,{y,z}}]=x_1; } if(x_2==0&&x<n&&q){ cout<<"? "<<x+1<<" "<<y<<" "<<z<<"\n"; q--; cin>>x_2; mp[{x+1,{y,z}}]=x_2; } if(y_1==0&&y>1&&q){ cout<<"? "<<x<<" "<<y-1<<" "<<z<<"\n"; q--; cin>>y_1; mp[{x,{y-1,z}}]=y_1; } if(y_2==0&&y<m&&q){ cout<<"? "<<x<<" "<<y+1<<" "<<z<<"\n"; q--; cin>>y_2; mp[{x,{y+1,z}}]=y_2; } if(z_1==0&&z>1&&q){ cout<<"? "<<x<<" "<<y<<" "<<z-1<<"\n"; q--; cin>>z_1; mp[{x,{y,z-1}}]=z_1; } if(z_2==0&&z<k&&q){ cout<<"? "<<x<<" "<<y<<" "<<z+1<<"\n"; q--; cin>>z_2; mp[{x,{y,z+1}}]=z_2; } int mx=max(max(x_1,x_2),max(max(y_1,y_2),max(z_1,z_2))); if(h>=mx)break; if(mx==x_1){ h=x_1; x--; b=1; } else if(mx==x_2){ h=x_2; x++; b=1; } else if(mx==y_1){ h=y_1; y--; b=1; } else if(mx==y_2){ h=y_2; y++; b=1; } else if(mx==z_1){ h=z_1; z--; b=1; } else if(mx==z_2){ h=z_2; z++; b=1; } } cout<<"! "<<x<<" "<<y<<" "<<z<<"\n"; }
#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...