Submission #369843

# Submission time Handle Problem Language Result Execution time Memory
369843 2021-02-22T15:41:48 Z TLP39 Aliens (IOI07_aliens) C++14
100 / 100
2 ms 384 KB
#include <bits/stdc++.h>
using namespace std;

char s[10];

bool que(int x,int y)
{
    printf("examine %d %d\n",x,y);
    fflush(stdout);
    scanf("%s",s);
    if(s[0]=='t') return true;
    else return false;
}

int main()
{
    int n,xi,yi;
    scanf("%d %d %d",&n,&xi,&yi);
    int hi,low,av;
    int maxm=n/5,m=1;
    int bot1,top1,left1,right1,bot5,left5;
    int ch1,ch2;

    hi=min(maxm,yi-1);
    low=0;
    while(hi>low)
    {
        av=(hi+low+1)/2;
        if(que(xi,yi-av))
        {
            ch1=que(xi,yi-av/2);
            ch2=que(xi,yi-av/4);
            if(ch1 && ch2) low=av;
            else hi=av-1;
        }
        else hi=av-1;
    }
    bot1=yi-hi;
    m+=hi;

    hi=min(maxm,n-yi);
    low=0;
    while(hi>low)
    {
        av=(hi+low+1)/2;
        if(que(xi,yi+av))
        {
            ch1=que(xi,yi+av/2);
            ch2=que(xi,yi+av/4);
            if(ch1 && ch2) low=av;
            else hi=av-1;
        }
        else hi=av-1;
    }
    top1=yi+hi;
    m+=hi;

    hi=min(m-1,xi-1);
    low=0;
    while(hi>low)
    {
        av=(hi+low+1)/2;
        if(que(xi-av,yi)) low=av;
        else hi=av-1;
    }
    left1=xi-hi;
    right1=xi-hi+m-1;

    int cap;
    for(cap=1;cap<=4;cap++)
    {
        if(yi-m*cap<1) break;
        if(cap%2)
        {
            if((xi-m<1 || !que(xi-m,yi-m*cap)) && (xi+m>n || !que(xi+m,yi-m*cap))) break;
        }
        else
        {
            if(!que(xi,yi-m*cap)) break;
        }
    }
    bot5=bot1-m*(cap-1);

    for(cap=1;cap<=4;cap++)
    {
        if(xi-m*cap<1) break;
        if(cap%2)
        {
            if((yi-m<1 || !que(xi-m*cap,yi-m)) && (yi+m>n || !que(xi-m*cap,yi+m))) break;
        }
        else
        {
            if(!que(xi-m*cap,yi)) break;
        }
    }
    left5=left1-m*(cap-1);
    printf("solution %d %d\n",left5+(5*m-1)/2,bot5+(5*m-1)/2);
    fflush(stdout);
}

Compilation message

aliens.cpp: In function 'int main()':
aliens.cpp:21:14: warning: variable 'top1' set but not used [-Wunused-but-set-variable]
   21 |     int bot1,top1,left1,right1,bot5,left5;
      |              ^~~~
aliens.cpp:21:25: warning: variable 'right1' set but not used [-Wunused-but-set-variable]
   21 |     int bot1,top1,left1,right1,bot5,left5;
      |                         ^~~~~~
aliens.cpp: In function 'bool que(int, int)':
aliens.cpp:10:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   10 |     scanf("%s",s);
      |     ~~~~~^~~~~~~~
aliens.cpp: In function 'int main()':
aliens.cpp:18:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   18 |     scanf("%d %d %d",&n,&xi,&yi);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 364 KB Output is correct
2 Correct 2 ms 364 KB Output is correct
3 Correct 2 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 2 ms 364 KB Output is correct