Submission #1188815

#TimeUsernameProblemLanguageResultExecution timeMemory
1188815racha555Aliens (IOI07_aliens)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
using namespace std;
define int long long 

bool ask(int x,int y){
   cout<<"examine ";
   cout<<x<<" "<<y<<" \n";
   string q;
   cin>>q;
   return q=="true";
}

signed main(){
      int n,x,y;
      cin>>n>>x>>y;
      int raya=1;
      while(ask(x+raya,y)){
         raya*=2;
         if(x+raya>n){
            raya=n-x;
           
            break;
         }
      }
      int l,mid,r;
      l=x,r=x+raya;
      int bestx=x;
      while(l<=r){
            mid=l+(r-l)/2;
            if(ask(mid,y)){
               l=mid+1;
               bestx=mid;
            }
            else{
               r=mid-1;
            }
      }
      raya=1;
      while(ask(bestx-raya,y)){
         raya*=2;
         if(bestx-raya<1){
            raya=bestx;
            break;
         }
      }
      l=bestx-raya,r=bestx;
      int badx=x;
      while(l<=r){
            mid=l+(r-l)/2;
            if(!ask(mid,y)){
               l=mid+1;
               badx=mid;
            }
            else{
               r=mid-1;
            }
      }
      badx+=1;
      // cout<<badx<<" "<<bestx;
      int m=bestx-badx+1;
      int midx=bestx-(m/2);
      int besty,bady;
      l=y;
      raya=1;
      while(ask(midx,y+raya)){
         raya*=2;
         if(y+raya>n){
            raya=r-y;

         }
      }
      l=y,r=y+raya;
       besty=y;
      while(l<=r){
            mid=l+(r-l)/2;
            if(ask(midx,mid)){
               l=mid+1;
               besty=mid;
            }
            else{
               r=mid-1;
            }
      }
      int midy=besty-m/2;
      // cout<<midx<<"--"<<midy; 
      bool still=true;
      while(still){
         still=false;
         if(ask(midx-m,midy+m)){
            still= true;
            midx=midx-m;
            midy=midy+m;
         }
         if(!still){
            if(ask(midx+m,midy+m)){
               still= true;
               midx=midx+m;
               midy=midy+m;
            }
         }
         if(!still){
            if(ask(midx-m,midy)){
               still= true;
               midx=midx-m;
               midy=midy;
            }
         }
      }
      cout<<"solution "<<midx+2*m<<" "<<midy-2*m;
}

Compilation message (stderr)

aliens.cpp:3:1: error: 'define' does not name a type
    3 | define int long long
      | ^~~~~~
aliens.cpp: In function 'int main()':
aliens.cpp:17:13: error: 'ask' was not declared in this scope
   17 |       while(ask(x+raya,y)){
      |             ^~~
aliens.cpp:30:16: error: 'ask' was not declared in this scope
   30 |             if(ask(mid,y)){
      |                ^~~
aliens.cpp:39:13: error: 'ask' was not declared in this scope
   39 |       while(ask(bestx-raya,y)){
      |             ^~~
aliens.cpp:50:17: error: 'ask' was not declared in this scope
   50 |             if(!ask(mid,y)){
      |                 ^~~
aliens.cpp:65:13: error: 'ask' was not declared in this scope
   65 |       while(ask(midx,y+raya)){
      |             ^~~
aliens.cpp:76:16: error: 'ask' was not declared in this scope
   76 |             if(ask(midx,mid)){
      |                ^~~
aliens.cpp:89:13: error: 'ask' was not declared in this scope
   89 |          if(ask(midx-m,midy+m)){
      |             ^~~
aliens.cpp:95:16: error: 'ask' was not declared in this scope
   95 |             if(ask(midx+m,midy+m)){
      |                ^~~
aliens.cpp:102:16: error: 'ask' was not declared in this scope
  102 |             if(ask(midx-m,midy)){
      |                ^~~