Submission #113395

# Submission time Handle Problem Language Result Execution time Memory
113395 2019-05-25T09:31:52 Z TadijaSebez Aliens (IOI07_aliens) C++11
100 / 100
4 ms 384 KB
#include <bits/stdc++.h>
using namespace std;
#define x0 xO
#define y0 yO
#define ll long long
#define int ll
int n,x0,y0;
int Ask(int x, int y)
{
	if(x>n || y>n || x<0 || y<0) return 0;
	printf("examine %i %i\n",x,y);
	fflush(stdout);
	char o[20];
	scanf("%s",o);
	if(o[0]=='t') return 1;
	else return 0;
}
void Answer(int x, int y)
{
	printf("solution %i %i\n",x,y);
	fflush(stdout);
}
#undef int
int main()
{
	#define int ll
	scanf("%i %i %i",&n,&x0,&y0);
	int hi,lo,mi;
	hi=n-x0,lo=0;
	for(mi=lo+hi+1>>1;lo<hi;mi=lo+hi+1>>1)
	{
		if(Ask(x0+mi,y0)) lo=mi;
		else hi=mi-1;
	}
	x0+=lo;
	hi=y0,lo=0;
	for(mi=lo+hi+1>>1;lo<hi;mi=lo+hi+1>>1)
	{
		if(Ask(x0,y0-mi)) lo=mi;
		else hi=mi-1;
	}
	y0-=lo;
	hi=min(n-x0,y0),lo=0;
	for(mi=lo+hi+1>>1;lo<hi;mi=lo+hi+1>>1)
	{
		if(Ask(x0+mi,y0-mi)) lo=mi;
		else hi=mi-1;
	}
	x0+=lo;y0-=lo;
	hi=min(x0,n-y0),lo=0;
	for(mi=lo+hi+1>>1;lo<hi;mi=lo+hi+1>>1)
	{
		if(Ask(x0-mi,y0+mi)) lo=mi;
		else hi=mi-1;
	}
	int x1=x0-lo,y1=y0+lo;
	int len=lo+1;
	if(len%5==0 && !Ask(x0-len/5,y0))
	{
		int x2=x0-(len-1)/2,y2=y0+(len-1)/2;
		Answer(x2,y2);
	}
	else if(len%3==0 && !Ask(x0-len/3,y0))
	{
		int m=len/3;
		len=m*5;
		if(Ask(x0+2*m,y0))
		{
			int x2=x0-(m-1)/2,y2=y0+(len-1)/2;
			Answer(x2,y2);
		}
		else
		{
			int x2=x0-(len-1)/2,y2=y0+(m-1)/2;
			Answer(x2,y2);
		}
	}
	else
	{
		int m=len;
		len=m*5;
		if(Ask(x0+2*m,y0))
		{
			int x2=x0-m+1+(len-1)/2,y2=y0+(len-1)/2;
			Answer(x2,y2);
		}
		else
		{
			int x2=x0-(len-1)/2,y2=y0+m-1-(len-1)/2;
			Answer(x2,y2);
		}
	}
	return 0;
}

Compilation message

aliens.cpp: In function 'long long int Ask(long long int, long long int)':
aliens.cpp:11:30: warning: format '%i' expects argument of type 'int', but argument 2 has type 'long long int' [-Wformat=]
  printf("examine %i %i\n",x,y);
                              ^
aliens.cpp:11:30: warning: format '%i' expects argument of type 'int', but argument 3 has type 'long long int' [-Wformat=]
aliens.cpp: In function 'void Answer(long long int, long long int)':
aliens.cpp:20:31: warning: format '%i' expects argument of type 'int', but argument 2 has type 'long long int' [-Wformat=]
  printf("solution %i %i\n",x,y);
                               ^
aliens.cpp:20:31: warning: format '%i' expects argument of type 'int', but argument 3 has type 'long long int' [-Wformat=]
aliens.cpp: In function 'int main()':
aliens.cpp:27:29: warning: format '%i' expects argument of type 'int*', but argument 2 has type 'long long int*' [-Wformat=]
  scanf("%i %i %i",&n,&x0,&y0);
                   ~~        ^
aliens.cpp:27:29: warning: format '%i' expects argument of type 'int*', but argument 3 has type 'long long int*' [-Wformat=]
aliens.cpp:27:29: warning: format '%i' expects argument of type 'int*', but argument 4 has type 'long long int*' [-Wformat=]
aliens.cpp:30:14: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
  for(mi=lo+hi+1>>1;lo<hi;mi=lo+hi+1>>1)
         ~~~~~^~
aliens.cpp:30:34: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
  for(mi=lo+hi+1>>1;lo<hi;mi=lo+hi+1>>1)
                             ~~~~~^~
aliens.cpp:37:14: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
  for(mi=lo+hi+1>>1;lo<hi;mi=lo+hi+1>>1)
         ~~~~~^~
aliens.cpp:37:34: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
  for(mi=lo+hi+1>>1;lo<hi;mi=lo+hi+1>>1)
                             ~~~~~^~
aliens.cpp:44:14: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
  for(mi=lo+hi+1>>1;lo<hi;mi=lo+hi+1>>1)
         ~~~~~^~
aliens.cpp:44:34: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
  for(mi=lo+hi+1>>1;lo<hi;mi=lo+hi+1>>1)
                             ~~~~~^~
aliens.cpp:51:14: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
  for(mi=lo+hi+1>>1;lo<hi;mi=lo+hi+1>>1)
         ~~~~~^~
aliens.cpp:51:34: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
  for(mi=lo+hi+1>>1;lo<hi;mi=lo+hi+1>>1)
                             ~~~~~^~
aliens.cpp:56:6: warning: unused variable 'x1' [-Wunused-variable]
  int x1=x0-lo,y1=y0+lo;
      ^~
aliens.cpp:56:15: warning: unused variable 'y1' [-Wunused-variable]
  int x1=x0-lo,y1=y0+lo;
               ^~
aliens.cpp: In function 'long long int Ask(long long int, long long int)':
aliens.cpp:14:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%s",o);
  ~~~~~^~~~~~~~
aliens.cpp: In function 'int main()':
aliens.cpp:27:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%i %i %i",&n,&x0,&y0);
  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 3 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 4 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 256 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 3 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 304 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 3 ms 256 KB Output is correct
3 Correct 3 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 384 KB Output is correct