Submission #338756

#TimeUsernameProblemLanguageResultExecution timeMemory
338756Ahmad_HasanAliens (IOI07_aliens)C++17
0 / 100
4 ms384 KiB
#include <bits/stdc++.h> using namespace std; int n,x,y; bool examn(int xe,int ye){ if(xe<1||xe>n||ye<1||ye>n) return false; /**if(abs(xe-x)%6<=1&&abs(ye-y)%6<=1) return true; return false;*/ cout<<"examine"<<' '<<xe<<' '<<ye<<'\n'; fflush(stdout); string in; cin>>in; if(in=="true") return true; return false; } bool examnx(int xb,int yb,int xe){ if(xe<1) return false; if(xb>xe){ int l=xb,r=xe; while(examn(r,yb)&&l>r){ r=l-(r-l)/2; } if(r>=l) return true; return false; }else{ int l=xb,r=xe; while(examn(r,yb)&&r>l){ r=(r-l)/2+l; } if(r<=l) return true; return false; } } bool examny(int xb,int yb,int ye){ if(ye<1) return false; if(yb>ye){ int l=yb,r=ye; while(examn(xb,r)&&l>r){ r=l-(r-l)/2; } if(r>=l) return true; return false; }else{ int l=yb,r=ye; while(examn(xb,r)&&r>l){ r=(r-l)/2+l; } if(r<=l) return true; return false; } } int main() { cin>>n>>x>>y; int l=0,r=1e9; int ux,lx,ly,ry; while(l<=r){ int mid=(r-l)/2+l; if(examnx(x,y,x+mid)){ ux=x+mid; l=mid+1; }else{ r=mid-1; } } l=0,r=1e9; while(l<=r){ cout<<l<<' '<<r<<'\n'; int mid=(r-l)/2+l; if(examnx(x,y,x-mid)){ lx=x-mid; l=mid+1; }else{ r=mid-1; } } cout<<lx<<"Done X\n"; l=0,r=1e9; while(l<=r){ int mid=(r-l)/2+l; if(examny(x,y,y+mid)){ ry=y+mid; l=mid+1; }else{ r=mid-1; } } l=0,r=1e9; while(l<=r){ int mid=(r-l)/2+l; if(examny(x,y,y-mid)){ ly=y-mid; l=mid+1; }else{ r=mid-1; } } cout<<"Done Y\n"; int h=0,w=0; l=0,r=1e9; int up=0; while(l<=r){ int mid=(r-l)/2+l; if(examn(x,ry+2*(ry-ly+1)*mid)){ l=mid+1; up=ry+2*(ry-ly+1)*mid; }else{ r=mid-1; } } l=0,r=1e9; int dn=0; while(l<=r){ int mid=(r-l)/2+l; if(examn(x,ly-2*(ry-ly+1)*mid)){ l=mid+1; dn=ly-2*(ry-ly+1)*mid; }else{ r=mid-1; } } l=0,r=1e9; int rt=0; while(l<=r){ int mid=(r-l)/2+l; if(examn(ux+2*(ry-ly+1)*mid,y)){ l=mid+1; rt=ux+2*(ry-ly+1)*mid; }else{ r=mid-1; } } l=0,r=1e9; int lf=0; while(l<=r){ int mid=(r-l)/2+l; if(examn(lx-2*(ry-ly+1)*mid,y)){ l=mid+1; lf=lx-2*(ry-ly+1)*mid; }else{ r=mid-1; } } cout<<"solution "<<(rt-lf)/2+lf<<' '<<(up-dn)/2+dn; fflush(stdout); return 0; } /**** 1 8 4 3 1 4 3 1 8 8 7 1 100 9 1 100 2 1 3 2 4 3 5 4 100 99 99 98 98 97 97 96 */

Compilation message (stderr)

aliens.cpp: In function 'int main()':
aliens.cpp:118:9: warning: unused variable 'h' [-Wunused-variable]
  118 |     int h=0,w=0;
      |         ^
aliens.cpp:118:13: warning: unused variable 'w' [-Wunused-variable]
  118 |     int h=0,w=0;
      |             ^
aliens.cpp:134:17: warning: 'ly' may be used uninitialized in this function [-Wmaybe-uninitialized]
  134 |         if(examn(x,ly-2*(ry-ly+1)*mid)){
      |            ~~~~~^~~~~~~~~~~~~~~~~~~~~~
aliens.cpp:123:17: warning: 'ry' may be used uninitialized in this function [-Wmaybe-uninitialized]
  123 |         if(examn(x,ry+2*(ry-ly+1)*mid)){
      |            ~~~~~^~~~~~~~~~~~~~~~~~~~~~
aliens.cpp:156:17: warning: 'lx' may be used uninitialized in this function [-Wmaybe-uninitialized]
  156 |         if(examn(lx-2*(ry-ly+1)*mid,y)){
      |            ~~~~~^~~~~~~~~~~~~~~~~~~~~~
aliens.cpp:145:17: warning: 'ux' may be used uninitialized in this function [-Wmaybe-uninitialized]
  145 |         if(examn(ux+2*(ry-ly+1)*mid,y)){
      |            ~~~~~^~~~~~~~~~~~~~~~~~~~~~
#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...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...