Submission #64082

#TimeUsernameProblemLanguageResultExecution timeMemory
64082baboWorm Worries (BOI18_worm)C++14
0 / 100
4 ms468 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); //if(x>=n/2) return mp[(S){x,y,z}]=n-x; //else return mp[(S){x,y,z}]=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; } } for(i=s;i<=e;i++) { L temp=ask(i,1,1); if(temp>ma) { ma=temp; mad=i; } } 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 '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:99: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); 
  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#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...