Submission #396345

# Submission time Handle Problem Language Result Execution time Memory
396345 2021-04-29T19:55:13 Z MarcoMeijer Aliens (IOI07_aliens) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;
 
// macros
typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<ll, ll> lll;
typedef tuple<int, int, int> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<ll> vll;
typedef vector<lll> vlll;
#define REP(a,b,c) for(int a=int(b); a<int(c); a++)
#define RE(a,c) REP(a,0,c)
#define RE1(a,c) REP(a,1,c+1)
#define REI(a,b,c) REP(a,b,c+1)
#define REV(a,b,c) for(int a=int(c-1); a>=int(b); a--)
#define FOR(a,b) for(auto& a : b)
#define all(a) a.begin(), a.end()
#define INF 1e18
#define EPS 1e-9
#define pb push_back
#define popb pop_back
#define fi first
#define se second
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
 
// input
template<class T> void IN(T& x) {cin >> x;}
template<class H, class... T> void IN(H& h, T&... t) {IN(h); IN(t...); }
 
// output
template<class T1, class T2> void OUT(const pair<T1,T2>& x);
template<class T> void OUT(const vector<T>& x);
template<class T> void OUT(const T& x) {cout << x;}
template<class H, class... T> void OUT(const H& h, const T&... t) {OUT(h); OUT(t...); }
template<class T1, class T2> void OUT(const pair<T1,T2>& x) {OUT(x.fi,' ',x.se);}
template<class T> void OUT(const vector<T>& x) {RE(i,x.size()) OUT(i==0?"":" ",x[i]);}
template<class... T> void OUTL(const T&... t) {OUT(t..., "\n"); }
template<class H> void OUTLS(const H& h) {OUTL(h); }
template<class H, class... T> void OUTLS(const H& h, const T&... t) {OUT(h,' '); OUTLS(t...); }
 
// dp
template<class T> bool ckmin(T&a, T&b) { bool bl = a > b; a = min(a,b); return bl;}
template<class T> bool ckmax(T&a, T&b) { bool bl = a < b; a = max(a,b); return bl;}
 
void program();
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    program();
}
 
 
//===================//
//   begin program   //
//===================//
 
const int MX = 5e5;
const int N = (1<<20);

ll n, m;
ll x0, y0;

bool query(ll x, ll y) {
    if(x > n || y > 1 || x <= 0 || y <= 0) return 0;
    OUTLS("examine",x,y);
    cout.flush();
    string res; IN(res);
    return res == "true";
}
void answer(ll x, ll y) {
    OUTLS("solution",x,y);
}
void goLeft() {
    RE(i,32) if(query(x0-(1ll<<i), y0)) x0 -= 1ll<<i;
}
void goRight() {
    RE(i,32) if(query(x0+(1ll<<i), y0)) x0 += 1ll<<i;
}
void goUp() {
    RE(i,32) if(query(x0, y0-(1ll<<i))) y0 -= 1ll<<i;
}
void goDown() {
    RE(i,32) if(query(x0, y0+(1ll<<i))) y0 += 1ll<<i;
}

bool checkM(int m) {
    RE(i,5) RE(j,5) {
        if((i+j)%2) continue;
        if(!query(x0+i*m,y0+j*m)) return false;
    }
    return true;
}

void program() {
    IN(n,x0,y0);
    goLeft();
    goUp();
    // we are currently in a top left cell
    int tlX=x0, tlY=y0;
    goRight();
    vll possibleM;
    possibleM.pb(x0-tlX+1);
    possibleM.pb((x0-tlX+1)/3);
    possibleM.pb((x0-tlX+1)/5);
    goLeft();

    FOR(m,possibleM) {
        while(query(x0-m, y0-m)) x0-=m, y0-=m;
        while(query(x0-m*2, y0)) x0-=m*2;
        while(query(x0, y0-m*2)) y0-=m*2;
    }

    // we are now at THE top left cell
    FOR(m,possibleM) if(checkM(m)) {
        // we found the value of m
        answer(x0+2*m+m/2,y0+2*m+m/2);
        return;
    }
}

Compilation message

aliens.cpp:66:8: error: 'll y0' redeclared as different kind of entity
   66 | ll x0, y0;
      |        ^~
In file included from /usr/include/features.h:424,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/os_defines.h:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/c++config.h:524,
                 from /usr/include/c++/9/cassert:43,
                 from /usr/include/x86_64-linux-gnu/c++/9/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 'void goLeft()':
aliens.cpp:79:36: error: invalid conversion from 'double (*)(double) throw ()' {aka 'double (*)(double)'} to 'll' {aka 'long long int'} [-fpermissive]
   79 |     RE(i,32) if(query(x0-(1ll<<i), y0)) x0 -= 1ll<<i;
      |                                    ^~
      |                                    |
      |                                    double (*)(double) throw () {aka double (*)(double)}
aliens.cpp:68:21: note:   initializing argument 2 of 'bool query(ll, ll)'
   68 | bool query(ll x, ll y) {
      |                  ~~~^
aliens.cpp: In function 'void goRight()':
aliens.cpp:82:36: error: invalid conversion from 'double (*)(double) throw ()' {aka 'double (*)(double)'} to 'll' {aka 'long long int'} [-fpermissive]
   82 |     RE(i,32) if(query(x0+(1ll<<i), y0)) x0 += 1ll<<i;
      |                                    ^~
      |                                    |
      |                                    double (*)(double) throw () {aka double (*)(double)}
aliens.cpp:68:21: note:   initializing argument 2 of 'bool query(ll, ll)'
   68 | bool query(ll x, ll y) {
      |                  ~~~^
aliens.cpp: In function 'void goUp()':
aliens.cpp:85:29: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   85 |     RE(i,32) if(query(x0, y0-(1ll<<i))) y0 -= 1ll<<i;
      |                           ~~^~~~~~~~~
aliens.cpp:85:29: error: invalid conversion from 'double (*)(double) throw ()' {aka 'double (*)(double)'} to 'll' {aka 'long long int'} [-fpermissive]
aliens.cpp:68:21: note:   initializing argument 2 of 'bool query(ll, ll)'
   68 | bool query(ll x, ll y) {
      |                  ~~~^
aliens.cpp:85:44: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   85 |     RE(i,32) if(query(x0, y0-(1ll<<i))) y0 -= 1ll<<i;
      |                                         ~~~^~~~~~~~~
aliens.cpp:85:44: error: assignment of read-only location 'y0'
aliens.cpp: In function 'void goDown()':
aliens.cpp:88:29: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   88 |     RE(i,32) if(query(x0, y0+(1ll<<i))) y0 += 1ll<<i;
      |                           ~~^~~~~~~~~
aliens.cpp:88:29: error: invalid conversion from 'double (*)(double) throw ()' {aka 'double (*)(double)'} to 'll' {aka 'long long int'} [-fpermissive]
aliens.cpp:68:21: note:   initializing argument 2 of 'bool query(ll, ll)'
   68 | bool query(ll x, ll y) {
      |                  ~~~^
aliens.cpp:88:44: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   88 |     RE(i,32) if(query(x0, y0+(1ll<<i))) y0 += 1ll<<i;
      |                                         ~~~^~~~~~~~~
aliens.cpp:88:44: error: assignment of read-only location 'y0'
aliens.cpp: In function 'bool checkM(int)':
aliens.cpp:94:28: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   94 |         if(!query(x0+i*m,y0+j*m)) return false;
      |                          ~~^~~~
aliens.cpp:94:28: error: invalid conversion from 'double (*)(double) throw ()' {aka 'double (*)(double)'} to 'll' {aka 'long long int'} [-fpermissive]
aliens.cpp:68:21: note:   initializing argument 2 of 'bool query(ll, ll)'
   68 | bool query(ll x, ll y) {
      |                  ~~~^
aliens.cpp: In function 'void program()':
aliens.cpp:104:21: error: invalid conversion from 'double (*)(double) throw ()' {aka 'double (*)(double)'} to 'int' [-fpermissive]
  104 |     int tlX=x0, tlY=y0;
      |                     ^~
      |                     |
      |                     double (*)(double) throw () {aka double (*)(double)}
aliens.cpp:113:29: warning: pointer to a function used in arithmetic [-Wpointer-arith]
  113 |         while(query(x0-m, y0-m)) x0-=m, y0-=m;
      |                           ~~^~
aliens.cpp:113:29: error: invalid conversion from 'double (*)(double) throw ()' {aka 'double (*)(double)'} to 'll' {aka 'long long int'} [-fpermissive]
aliens.cpp:68:21: note:   initializing argument 2 of 'bool query(ll, ll)'
   68 | bool query(ll x, ll y) {
      |                  ~~~^
aliens.cpp:113:43: warning: pointer to a function used in arithmetic [-Wpointer-arith]
  113 |         while(query(x0-m, y0-m)) x0-=m, y0-=m;
      |                                         ~~^~~
aliens.cpp:113:43: error: assignment of read-only location 'y0'
aliens.cpp:114:29: error: invalid conversion from 'double (*)(double) throw ()' {aka 'double (*)(double)'} to 'll' {aka 'long long int'} [-fpermissive]
  114 |         while(query(x0-m*2, y0)) x0-=m*2;
      |                             ^~
      |                             |
      |                             double (*)(double) throw () {aka double (*)(double)}
aliens.cpp:68:21: note:   initializing argument 2 of 'bool query(ll, ll)'
   68 | bool query(ll x, ll y) {
      |                  ~~~^
aliens.cpp:115:27: warning: pointer to a function used in arithmetic [-Wpointer-arith]
  115 |         while(query(x0, y0-m*2)) y0-=m*2;
      |                         ~~^~~~
aliens.cpp:115:27: error: invalid conversion from 'double (*)(double) throw ()' {aka 'double (*)(double)'} to 'll' {aka 'long long int'} [-fpermissive]
aliens.cpp:68:21: note:   initializing argument 2 of 'bool query(ll, ll)'
   68 | bool query(ll x, ll y) {
      |                  ~~~^
aliens.cpp:115:36: warning: pointer to a function used in arithmetic [-Wpointer-arith]
  115 |         while(query(x0, y0-m*2)) y0-=m*2;
      |                                  ~~^~~~~
aliens.cpp:115:36: error: assignment of read-only location 'y0'
aliens.cpp:121:29: warning: pointer to a function used in arithmetic [-Wpointer-arith]
  121 |         answer(x0+2*m+m/2,y0+2*m+m/2);
      |                           ~~^~~~
aliens.cpp:121:33: warning: pointer to a function used in arithmetic [-Wpointer-arith]
  121 |         answer(x0+2*m+m/2,y0+2*m+m/2);
      |                           ~~~~~~^~~~
aliens.cpp:121:33: error: invalid conversion from 'double (*)(double) throw ()' {aka 'double (*)(double)'} to 'll' {aka 'long long int'} [-fpermissive]
aliens.cpp:75:22: note:   initializing argument 2 of 'void answer(ll, ll)'
   75 | void answer(ll x, ll y) {
      |                   ~~~^
aliens.cpp:104:17: warning: unused variable 'tlY' [-Wunused-variable]
  104 |     int tlX=x0, tlY=y0;
      |                 ^~~
aliens.cpp: In instantiation of 'void IN(T&) [with T = double(double)]':
aliens.cpp:32:64:   recursively required from 'void IN(H&, T& ...) [with H = long long int; T = {double(double)}]'
aliens.cpp:32:64:   required from 'void IN(H&, T& ...) [with H = long long int; T = {long long int, double(double)}]'
aliens.cpp:100:15:   required from here
aliens.cpp:31:38: error: no match for 'operator>>' (operand types are 'std::istream' {aka 'std::basic_istream<char>'} and 'double(double)')
   31 | template<class T> void IN(T& x) {cin >> x;}
      |                                  ~~~~^~~~
In file included from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from aliens.cpp:1:
/usr/include/c++/9/istream:120:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(std::basic_istream<_CharT, _Traits>::__istream_type& (*)(std::basic_istream<_CharT, _Traits>::__istream_type&)) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>]' <near match>
  120 |       operator>>(__istream_type& (*__pf)(__istream_type&))
      |       ^~~~~~~~
/usr/include/c++/9/istream:120:7: note:   conversion of argument 1 would be ill-formed:
aliens.cpp:31:38: error: invalid conversion from 'double (*)(double)' to 'std::basic_istream<char>::__istream_type& (*)(std::basic_istream<char>::__istream_type&)' {aka 'std::basic_istream<char>& (*)(std::basic_istream<char>&)'} [-fpermissive]
   31 | template<class T> void IN(T& x) {cin >> x;}
      |                                  ~~~~^~~~
      |                                      |
      |                                      double (*)(double)
In file included from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from aliens.cpp:1:
/usr/include/c++/9/istream:124:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(std::basic_istream<_CharT, _Traits>::__ios_type& (*)(std::basic_istream<_CharT, _Traits>::__ios_type&)) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>; std::basic_istream<_CharT, _Traits>::__ios_type = std::basic_ios<char>]' <near match>
  124 |       operator>>(__ios_type& (*__pf)(__ios_type&))
      |       ^~~~~~~~
/usr/include/c++/9/istream:124:7: note:   conversion of argument 1 would be ill-formed:
aliens.cpp:31:38: error: invalid conversion from 'double (*)(double)' to 'std::basic_istream<char>::__ios_type& (*)(std::basic_istream<char>::__ios_type&)' {aka 'std::basic_ios<char>& (*)(std::basic_ios<char>&)'} [-fpermissive]
   31 | template<class T> void IN(T& x) {cin >> x;}
      |                                  ~~~~^~~~
      |                                      |
      |                                      double (*)(double)
In file included from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from aliens.cpp:1:
/usr/include/c++/9/istream:131:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(std::ios_base& (*)(std::ios_base&)) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>]' <near match>
  131 |       operator>>(ios_base& (*__pf)(ios_base&))
      |       ^~~~~~~~
/usr/include/c++/9/istream:131:7: note:   conversion of argument 1 would be ill-formed:
aliens.cpp:31:38: error: invalid conversion from 'double (*)(double)' to 'std::ios_base& (*)(std::ios_base&)' [-fpermissive]
   31 | template<class T> void IN(T& x) {cin >> x;}
      |                                  ~~~~^~~~
      |                                      |
      |                                      double (*)(double)
In file included from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from aliens.cpp:1:
/usr/include/c++/9/istream:168:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(bool&) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>]' <near match>
  168 |       operator>>(bool& __n)
      |       ^~~~~~~~
/usr/include/c++/9/istream:168:7: note:   conversion of argument 1 would be ill-formed:
aliens.cpp:31:38: warning: the compiler can assume that the address of 'x' will never be NULL [-Waddress]
   31 | template<class T> void IN(T& x) {cin >> x;}
      |                                  ~~~~^~~~
aliens.cpp:31:38: warning: the compiler can assume that the address of 'x' will never be NULL [-Waddress]
aliens.cpp:31:38: error: cannot bind non-const lvalue reference of type 'bool&' to an rvalue of type 'bool'
In file included from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from aliens.cpp:1:
/usr/include/c++/9/istream:172:7: note: candidate: 'std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(short int&) [with _CharT = char; _Traits = std::char_traits<char>]' <near match>
  172 |       operator>>(short& __n);
      |       ^~~~~~~~
/usr/include/c++/9/istream:172:7: note:   conversion of argument 1 would be ill-formed:
aliens.cpp:31:38: error: invalid conversion from 'double (*)(double)' to 'short int' [-fpermissive]
   31 | template<class T> void IN(T& x) {cin >> x;}
      |                                  ~~~~^~~~
      |                                      |
      |                                      double (*)(double)
aliens.cpp:31:38: error: cannot bind rvalue '(short int)(& x)' to 'short int&'
In file included from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from aliens.cpp:1:
/usr/include/c++/9/istream:175:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(short unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>]' <near match>
  175 |       operator>>(unsigned short& __n)
      |       ^~~~~~~~
/usr/include/c++/9/istream:175:7: note:   conversion of argument 1 would be ill-formed:
aliens.cpp:31:38: error: invalid conversion from 'double (*)(double)' to 'short unsigned int' [-fpermissive]
   31 | template<class T> void IN(T& x) {cin >> x;}
      |                                  ~~~~^~~~
      |                                      |
      |                                      double (*)(double)
aliens.cpp:31:38: error: cannot bind rvalue '(short unsigned int)(& x)' to 'short unsigned int&'
In file included from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from aliens.cpp:1:
/usr/include/c++/9/istream:179:7: note: candidate: 'std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(int&) [with _CharT = char; _Traits = std::char_traits<char>]' <near match>
  179 |       operator>>(int& __n);
      |       ^~~~~~~~
/usr/include/c++/9/istream:179:7: note:   conversion of argument 1 would be ill-formed:
aliens.cpp:31:38: error: invalid conversion from 'double (*)(double)' to 'int' [-fpermissive]
   31 | template<class T> void IN(T& x) {cin >> x;}
      |                                  ~~~~^~~~
      |                                      |
      |                                      double (*)(double)
aliens.cpp:31:38: error: cannot bind rvalue '(int)(& x)' to 'int&'
In file included from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from aliens.cpp:1:
/usr/include/c++/9/istream:182:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>]' <near match>
  182 |       operator>>(unsigned int& __n)
      |       ^~~~~~~~
/usr/include/c++/9/istream:182:7: note:   conversion of argument 1 would be ill-formed:
aliens.cpp:31:38: error: invalid conversion from 'double (*)(double)' to 'unsigned int' [-fpermissive]
   31 | template<class T> void IN(T& x) {cin >> x;}
      |                                  ~~~~^~~~
      |                                      |
      |                                      double (*)(double)
aliens.cpp:31:38: error: cannot bind rvalue '(unsigned int)(& x)' to 'unsigned int&'
In file included from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from aliens.cpp:1:
/usr/include/c++/9/istream:186:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long int&) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>]' <near match>
  186 |       operator>>(long& __n)
      |       ^~~~~~~~
/usr/include/c++/9/istream:186:7: note:   conversion of argument 1 would be ill-formed:
aliens.cpp:31:38: error: invalid conversion from 'double (*)(double)' to 'long int' [-fpermissive]
   31 | template<class T> void IN(T& x) {cin >> x;}
      |                                  ~~~~^~~~
      |                                      |