Submission #1154554

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

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

bool inpoot(long long x, long long 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";
}

int32_t main(){

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

    int s = 1;

    while(inpoot(s + X - 1,Y) || inpoot(X - s + 1,Y)) s *= 2;
    if(s != 1) s/=2;

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

        while(inpoot(lX - s + 1,Y)) lX +=  - s + 1;
        while(inpoot(rX + s - 1,Y)) rX += s - 1;
    }
    else{
        lX = X;
        rX = X;
    }


//printf("%d %d\n",lX,rX);
    int ns = 0;
    int e = s - 1;

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

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

    lX -= ns;

    ns = 0;
    e = s - 1;

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

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

    rX += ns;

    int L = rX - lX + 1;
//printf("%d %d %d\n",lX,rX,L);
    lY = Y;
    rY = Y;

    ns = 0;
    e = L - 1;

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

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

    lY -= ns;

    rY = lY + L - 1;

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

    int temp;

    int lcont = 0;
    int rcont = 0;

    while((lcont < 2) && inpoot(X - 2 * L * (1 + lcont), Y )) lcont++;
    while((lcont + rcount < 2) && inpoot(X + 2 * L * (1 + rcont), Y )) rcont++;

    rcont -= lcont;

    int x = X;

    X += rcont * L;

    lcont = 0;
    rcont = 0;

    while((lcont < 2) && inpoot(x,Y - 2 * L * (1 + lcont) )) lcont++;
    while((lcont + rcount < 2) && inpoot(x,Y + 2 * L * (1 + rcont) )) rcont++;

    rcont -= lcont;

    Y += rcont * L;

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

Compilation message (stderr)

aliens.cpp: In function 'bool inpoot(long long int, long long int)':
aliens.cpp:16:22: warning: format '%d' expects argument of type 'int', but argument 2 has type 'long long int' [-Wformat=]
   16 |     printf("examine %d %d\n",x,y);
      |                     ~^       ~
      |                      |       |
      |                      int     long long int
      |                     %lld
aliens.cpp:16:25: warning: format '%d' expects argument of type 'int', but argument 3 has type 'long long int' [-Wformat=]
   16 |     printf("examine %d %d\n",x,y);
      |                        ~^      ~
      |                         |      |
      |                         int    long long int
      |                        %lld
aliens.cpp: In function 'int32_t main()':
aliens.cpp:115:20: error: 'rcount' was not declared in this scope; did you mean 'rcont'?
  115 |     while((lcont + rcount < 2) && inpoot(X + 2 * L * (1 + rcont), Y )) rcont++;
      |                    ^~~~~~
      |                    rcont
aliens.cpp:127:20: error: 'rcount' was not declared in this scope; did you mean 'rcont'?
  127 |     while((lcont + rcount < 2) && inpoot(x,Y + 2 * L * (1 + rcont) )) rcont++;
      |                    ^~~~~~
      |                    rcont
aliens.cpp:133:23: warning: format '%d' expects argument of type 'int', but argument 2 has type 'long long int' [-Wformat=]
  133 |     printf("solution %d %d\n",X,Y);
      |                      ~^       ~
      |                       |       |
      |                       int     long long int
      |                      %lld
aliens.cpp:133:26: warning: format '%d' expects argument of type 'int', but argument 3 has type 'long long int' [-Wformat=]
  133 |     printf("solution %d %d\n",X,Y);
      |                         ~^      ~
      |                          |      |
      |                          int    long long int
      |                         %lld
aliens.cpp:28:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   28 |     scanf(" %lld",&N);
      |     ~~~~~^~~~~~~~~~~~
aliens.cpp:29:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   29 |     scanf(" %lld",&X);
      |     ~~~~~^~~~~~~~~~~~
aliens.cpp:30:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   30 |     scanf(" %lld",&Y);
      |     ~~~~~^~~~~~~~~~~~