Submission #1154531

#TimeUsernameProblemLanguageResultExecution timeMemory
1154531salmonAliens (IOI07_aliens)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
using namespace std;

long long int N;
long long int X;
long long int Y;
long long int lX;
long long int rX;
long long int lY;
long long int rY;

bool inpoot(long long int x, long long int y){
    if(x < 1 || y < 1) return false;
    if(x > N || y > N) return false;
    printf("examine %d %d\n",x,y);
    fflush(stdout);

    string s;

    cin >> s;

    return s == "true";
}

int main(){

    scanf(" %lld",&N);
    scanf(" %lld",&X);
    scanf(" %lld",&Y);

    int s = 1;

    while(inpoot(s + X - 1) || inpoot(X - s + 1)) s *= 2;

    if(s != 1){
        lX = X;
        rX = X;

        while(inpoot(lX - s + 1)) lX +=  - s + 1;
        while(inpoot(rX + s - 1)) rX += s - 1;
    }


    int ns = 0;
    int e = s - 1;

    while(ns != e){
        int m = (ns + e + 1)/2;

        if(inpoot(lX - ns)){
            ns = m;
        }
        else{
            e = m - 1;
        }
    }

    lX -= s;

    ns = 0;
    e = s - 1;

    while(ns != e){
        int m = (ns + e + 1)/2;

        if(inpoot(rX + ns)){
            ns = m;
        }
        else{
            e = m - 1;
        }
    }

    rX += s;

    int L = rX - lX + 1;

    lY = Y;
    rY = Y;

    ns = 0;
    e = L - 1;

    while(ns != e){
        int m = (ns + e + 1)/2;

        if(inpoot(lY - ns)){
            ns = m;
        }
        else{
            e = m - 1;
        }
    }

    lY -= s;


    ns = 0;
    e = L - 1;

    while(ns != e){
        int m = (ns + e + 1)/2;

        if(inpoot(rY + ns)){
            ns = m;
        }
        else{
            e = m - 1;
        }
    }

    rY += s;

    X = (rX + lX)/2;
    Y = (rY + lY)/2;

    int temp;

    int lcont = 0;
    int rcont = 0;

    while(inpoot(X - 2 * L * (1 + lcont) )) lcont++;
    while(inpoot(X + 2 * l * (1 + rcount) )) rcount++;

    rcount -= lcount;

    X += rcount * L;

    lcont = 0;
    rcont = 0;

    while(inpoot(Y - 2 * L * (1 + lcont) )) lcont++;
    while(inpoot(Y + 2 * l * (1 + rcount) )) rcount++;

    Y += rcount * L;

    printf("%d %d\n",X,Y);
}

Compilation message (stderr)

aliens.cpp: In function 'bool inpoot(long long int, long long int)':
aliens.cpp:15:22: warning: format '%d' expects argument of type 'int', but argument 2 has type 'long long int' [-Wformat=]
   15 |     printf("examine %d %d\n",x,y);
      |                     ~^       ~
      |                      |       |
      |                      int     long long int
      |                     %lld
aliens.cpp:15:25: warning: format '%d' expects argument of type 'int', but argument 3 has type 'long long int' [-Wformat=]
   15 |     printf("examine %d %d\n",x,y);
      |                        ~^      ~
      |                         |      |
      |                         int    long long int
      |                        %lld
aliens.cpp: In function 'int main()':
aliens.cpp:33:17: error: too few arguments to function 'bool inpoot(long long int, long long int)'
   33 |     while(inpoot(s + X - 1) || inpoot(X - s + 1)) s *= 2;
      |           ~~~~~~^~~~~~~~~~~
aliens.cpp:12:6: note: declared here
   12 | bool inpoot(long long int x, long long int y){
      |      ^~~~~~
aliens.cpp:33:38: error: too few arguments to function 'bool inpoot(long long int, long long int)'
   33 |     while(inpoot(s + X - 1) || inpoot(X - s + 1)) s *= 2;
      |                                ~~~~~~^~~~~~~~~~~
aliens.cpp:12:6: note: declared here
   12 | bool inpoot(long long int x, long long int y){
      |      ^~~~~~
aliens.cpp:39:21: error: too few arguments to function 'bool inpoot(long long int, long long int)'
   39 |         while(inpoot(lX - s + 1)) lX +=  - s + 1;
      |               ~~~~~~^~~~~~~~~~~~
aliens.cpp:12:6: note: declared here
   12 | bool inpoot(long long int x, long long int y){
      |      ^~~~~~
aliens.cpp:40:21: error: too few arguments to function 'bool inpoot(long long int, long long int)'
   40 |         while(inpoot(rX + s - 1)) rX += s - 1;
      |               ~~~~~~^~~~~~~~~~~~
aliens.cpp:12:6: note: declared here
   12 | bool inpoot(long long int x, long long int y){
      |      ^~~~~~
aliens.cpp:50:18: error: too few arguments to function 'bool inpoot(long long int, long long int)'
   50 |         if(inpoot(lX - ns)){
      |            ~~~~~~^~~~~~~~~
aliens.cpp:12:6: note: declared here
   12 | bool inpoot(long long int x, long long int y){
      |      ^~~~~~
aliens.cpp:66:18: error: too few arguments to function 'bool inpoot(long long int, long long int)'
   66 |         if(inpoot(rX + ns)){
      |            ~~~~~~^~~~~~~~~
aliens.cpp:12:6: note: declared here
   12 | bool inpoot(long long int x, long long int y){
      |      ^~~~~~
aliens.cpp:87:18: error: too few arguments to function 'bool inpoot(long long int, long long int)'
   87 |         if(inpoot(lY - ns)){
      |            ~~~~~~^~~~~~~~~
aliens.cpp:12:6: note: declared here
   12 | bool inpoot(long long int x, long long int y){
      |      ^~~~~~
aliens.cpp:104:18: error: too few arguments to function 'bool inpoot(long long int, long long int)'
  104 |         if(inpoot(rY + ns)){
      |            ~~~~~~^~~~~~~~~
aliens.cpp:12:6: note: declared here
   12 | bool inpoot(long long int x, long long int y){
      |      ^~~~~~
aliens.cpp:122:17: error: too few arguments to function 'bool inpoot(long long int, long long int)'
  122 |     while(inpoot(X - 2 * L * (1 + lcont) )) lcont++;
      |           ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
aliens.cpp:12:6: note: declared here
   12 | bool inpoot(long long int x, long long int y){
      |      ^~~~~~
aliens.cpp:123:26: error: 'l' was not declared in this scope
  123 |     while(inpoot(X + 2 * l * (1 + rcount) )) rcount++;
      |                          ^
aliens.cpp:123:35: error: 'rcount' was not declared in this scope; did you mean 'rcont'?
  123 |     while(inpoot(X + 2 * l * (1 + rcount) )) rcount++;
      |                                   ^~~~~~
      |                                   rcont
aliens.cpp:125:5: error: 'rcount' was not declared in this scope; did you mean 'rcont'?
  125 |     rcount -= lcount;
      |     ^~~~~~
      |     rcont
aliens.cpp:125:15: error: 'lcount' was not declared in this scope; did you mean 'lcont'?
  125 |     rcount -= lcount;
      |               ^~~~~~
      |               lcont
aliens.cpp:132:17: error: too few arguments to function 'bool inpoot(long long int, long long int)'
  132 |     while(inpoot(Y - 2 * L * (1 + lcont) )) lcont++;
      |           ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
aliens.cpp:12:6: note: declared here
   12 | bool inpoot(long long int x, long long int y){
      |      ^~~~~~
aliens.cpp:133:26: error: 'l' was not declared in this scope
  133 |     while(inpoot(Y + 2 * l * (1 + rcount) )) rcount++;
      |                          ^
aliens.cpp:137:14: warning: format '%d' expects argument of type 'int', but argument 2 has type 'long long int' [-Wformat=]
  137 |     printf("%d %d\n",X,Y);
      |             ~^       ~
      |              |       |
      |              int     long long int
      |             %lld
aliens.cpp:137:17: warning: format '%d' expects argument of type 'int', but argument 3 has type 'long long int' [-Wformat=]
  137 |     printf("%d %d\n",X,Y);
      |                ~^      ~
      |                 |      |
      |                 int    long long int
      |                %lld
aliens.cpp:27:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   27 |     scanf(" %lld",&N);
      |     ~~~~~^~~~~~~~~~~~
aliens.cpp:28:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   28 |     scanf(" %lld",&X);
      |     ~~~~~^~~~~~~~~~~~
aliens.cpp:29:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   29 |     scanf(" %lld",&Y);
      |     ~~~~~^~~~~~~~~~~~