Submission #1256553

#TimeUsernameProblemLanguageResultExecution timeMemory
1256553jumpAliens (IOI07_aliens)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #define int long long int lim,x,y; int u,d,l,r; int USE = 0; bool test(int tx,int ty){ USE++; if(tx>lim||ty>lim||tx<0||ty<0)return false; std::cout << "examine " << tx << ' ' << ty << std::endl; std::string in; std::cin >> in; // if(ty>=max)return false; // else return true; return in[0]=='t'; } void ans(int tx,int ty){ std::cout << "solution " << tx << ' ' << ty << std::endl; } bool up(int x,int y,int t){return test(x,y+t);} bool down(int x,int y,int t){return test(x,y-t);} bool left(int x,int y,int t){return test(x-t,y);} bool right(int x,int y,int t){return test(x+t,y);} int find(std::function<bool(int,int,int)> f){ int l=1,h=-1; int last=l; while(h==-1){ if(f(x,y,l)){ last=l; l*=2; } else{ h = l; } } l=last; while(l<h){ int mid = (l+h+1)/2; if(f(x,y,mid)){ l = mid; } else{ h = mid-1; } } return l; } void fans(int cmx,int cmy,int m){ int tr=2; int xd=1; int yd=1; if(test(cmx+2*m,cmy))xd+=1; if(test(cmx+2*2*m,cmy))xd+=1; if(test(cmx,cmy+2*m))yd+=1; if(test(cmx,cmy+2*2*m))yd+=1; if((xd==1&&yd==2)||(xd==1&&yd==1)||(xd==2&&yd==1)){ if(test(cmx+m,cmy+m)){ int ax,ay; if(xd==1)ax = cmx-m; else ax = cmx+m if(yd==1)ay = cmy-m; else ay = cmy + m; ans(ax,ay); } else{ ans(cmx-(2-xd)*2*m,cmy-(2-yd)*2*m); } } else if(xd==2&&yd==2){ if(test(cmx-3*m,cmy-3*m)){ ans(cmx,cmy); } else{ ans(cmx+m,cmy+m); } } } signed main() { std::ios::sync_with_stdio(false);std::cin.tie(nullptr); std::cin >> lim >> x >> y; int u = find(up); int l = find(left); int r = find(right); int d = find(down); int m = (1+l+r); int cmx = x-l+m/2; int cmy = x-d+m/2; fans(cmx,cmy,m); }

Compilation message (stderr)

aliens.cpp: In function 'void fans(long long int, long long int, long long int)':
aliens.cpp:60:40: error: expected ';' before 'if'
   60 |                         else ax = cmx+m
      |                                        ^
      |                                        ;
   61 |                         if(yd==1)ay = cmy-m;
      |                         ~~              
aliens.cpp:62:25: error: expected '}' before 'else'
   62 |                         else ay = cmy + m;
      |                         ^~~~
aliens.cpp:57:38: note: to match this '{'
   57 |                 if(test(cmx+m,cmy+m)){
      |                                      ^
aliens.cpp:62:30: error: 'ay' was not declared in this scope; did you mean 'y'?
   62 |                         else ay = cmy + m;
      |                              ^~
      |                              y
aliens.cpp:63:29: error: 'ax' was not declared in this scope; did you mean 'x'?
   63 |                         ans(ax,ay);
      |                             ^~
      |                             x
aliens.cpp:63:32: error: 'ay' was not declared in this scope; did you mean 'y'?
   63 |                         ans(ax,ay);
      |                                ^~
      |                                y
aliens.cpp: At global scope:
aliens.cpp:69:9: error: expected unqualified-id before 'else'
   69 |         else if(xd==2&&yd==2){
      |         ^~~~
aliens.cpp:77:1: error: expected declaration before '}' token
   77 | }
      | ^