Submission #922596

#TimeUsernameProblemLanguageResultExecution timeMemory
922596Rainmaker2627Aliens (IOI07_aliens)C++17
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> using namespace std; int n, x0, y0; bool inside(int x, int y) { return (x>0 && y>0 && x<=n && y<=n); } bool examine(int i, int j) { if (!inside(i, j)) return false; cout << "examine " << i << ' ' << j << endl; string s; cin >> s; return s[0]=='t'; } int find(int r, int d) { int i=0; while (examine(x0+(r<<i), y0+(d<<i))) i++; int lo=(1<<(i-1))-1, hi=(1<<i)-1; while (lo<hi) { int mid=(lo+hi)/2; if (query(x0+mid*r, y0+mid*d)) lo=mid; else hi=mid; } return hi; } int main() { cin.tie(0)->sync_with_stdio(false); int n, x, y; cin >> n >> x >> y; int r=find(1, 0), l=find(-1, 0), b=find(0, 1); int sz=r-l+1, t=b-sz; int x=(r+l)/2, y=(t+b)/2; while(examine(x+2*sz, y)) x+=2*sz; while(examine(x, y+2*sz)) y+=2*sz; while(examine(x+sz, y+sz)) x+=sz, y+=sz; cout << "solution " << x-2*sz << ' ' << y-2*sz << endl; return 0; }

Compilation message (stderr)

aliens.cpp:4:12: error: 'int y0' redeclared as different kind of entity
    4 | int n, x0, y0;
      |            ^~
In file included from /usr/include/features.h:461,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/os_defines.h:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/c++config.h:518,
                 from /usr/include/c++/10/cassert:43,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:33,
                 from aliens.cpp:1:
/usr/include/x86_64-linux-gnu/bits/mathcalls.h:220:1: note: previous declaration 'double y0(double)'
  220 | __MATHCALL (y0,, (_Mdouble_));
      | ^~~~~~~~~~
aliens.cpp: In function 'int find(int, int)':
aliens.cpp:18:30: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   18 |  while (examine(x0+(r<<i), y0+(d<<i))) i++;
      |                            ~~^~~~~~~
aliens.cpp:18:30: error: invalid conversion from 'double (*)(double) noexcept' to 'int' [-fpermissive]
aliens.cpp:8:25: note:   initializing argument 2 of 'bool examine(int, int)'
    8 | bool examine(int i, int j) {
      |                     ~~~~^
aliens.cpp:22:25: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   22 |   if (query(x0+mid*r, y0+mid*d)) lo=mid;
      |                       ~~^~~~~~
aliens.cpp:22:7: error: 'query' was not declared in this scope
   22 |   if (query(x0+mid*r, y0+mid*d)) lo=mid;
      |       ^~~~~
aliens.cpp: In function 'int main()':
aliens.cpp:35:6: error: redeclaration of 'int x'
   35 |  int x=(r+l)/2, y=(t+b)/2;
      |      ^
aliens.cpp:30:9: note: 'int x' previously declared here
   30 |  int n, x, y;
      |         ^
aliens.cpp:35:17: error: redeclaration of 'int y'
   35 |  int x=(r+l)/2, y=(t+b)/2;
      |                 ^
aliens.cpp:30:12: note: 'int y' previously declared here
   30 |  int n, x, y;
      |            ^