Submission #64088

#TimeUsernameProblemLanguageResultExecution timeMemory
64088baboWorm Worries (BOI18_worm)C++14
0 / 100
3 ms588 KiB
#include <bits/stdc++.h> #define L long long using namespace std; L n,m,k,q; L cnt; const double distribution=2.61803398874; struct S{ L x,y,z; }; bool operator<(S a,S b){ if(a.x!=b.x) return a.x<b.x; if(a.y!=b.y) return a.y<b.y; return a.z<b.z; } map<S,L>mp; L ask(L x,L y,L z){ if(mp[(S){x,y,z}]) return mp[(S){x,y,z}]; cnt++; //printf("%lld\n",cnt); printf("? %lld %lld %lld\n",x,y,z); fflush(stdout); L ret; scanf("%lld",&ret); //return mp[(S){x,y,z}]=10000000-(x>5?x-5:5-x); if(ret==-1) exit(0); else return mp[(S){x,y,z}]=ret; } void answer(S ans){ printf("! %lld %lld %lld\n",ans.x,ans.y,ans.z); } L hf(double x){ L ret=(L)x; if(x-ret>0.5) ret++; return ret; } void dim1(){ L s=1,e=n,mi1=0,mi2=0,i,ma=0,mad; while(s<e-2) { if(!mi1&&!mi2) { mi1=s+hf((e-s)/distribution); mi2=e-hf((e-s)/distribution); } else if(!mi1) { mi1=s+hf((e-s)/distribution); } else if(!mi2) { mi2=e-hf((e-s)/distribution); } L lef=ask(mi1,1,1); L rig=ask(mi2,1,1); if(lef>rig) { e=mi2; mi2=mi1; mi1=0; } else { s=mi1; mi1=mi2; mi2=0; } } while(s<e) { L mi1=(s+e)/2; L mi2=mi1+1; L lef=ask(mi1,1,1); L rig=ask(mi2,1,1); if(lef>rig) { e=mi1; } else { s=mi2; } } answer((S){mad,1,1}); } void dim2(){ } void dim3(){ } int main() { srand((int)time(NULL)); scanf("%lld %lld %lld %lld",&n,&m,&k,&q); if(m==1&&k==1) { dim1(); } else if(k==1) { dim2(); } else { dim3(); } }

Compilation message (stderr)

worm.cpp: In function 'void dim1()':
worm.cpp:45:24: warning: unused variable 'i' [-Wunused-variable]
  L s=1,e=n,mi1=0,mi2=0,i,ma=0,mad;
                        ^
worm.cpp:45:26: warning: unused variable 'ma' [-Wunused-variable]
  L s=1,e=n,mi1=0,mi2=0,i,ma=0,mad;
                          ^~
worm.cpp: In function 'long long int ask(long long int, long long int, long long int)':
worm.cpp:28:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld",&ret);
  ~~~~~^~~~~~~~~~~~~
worm.cpp: In function 'int main()':
worm.cpp:104:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld %lld %lld %lld",&n,&m,&k,&q); 
  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
worm.cpp: In function 'void dim1()':
worm.cpp:91:8: warning: 'mad' is used uninitialized in this function [-Wuninitialized]
  answer((S){mad,1,1});
  ~~~~~~^~~~~~~~~~~~~~
#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...