답안 #113377

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
113377 2019-05-25T09:14:35 Z TadijaSebez Aliens (IOI07_aliens) C++11
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;
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);
}
int main()
{
	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,y0-len/5))
	{
		int x2=x0-(len-1)/2,y2=y0+(len-1)/2;
		Answer(x2,y2);
	}
	else if(len%3==0 && !Ask(x0,y0-len/3))
	{
		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:3:10: error: 'int y0' redeclared as different kind of symbol
 int n,x0,y0;
          ^~
In file included from /usr/include/features.h:367:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/os_defines.h:39,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/c++config.h:533,
                 from /usr/include/c++/7/cassert:43,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:33,
                 from aliens.cpp:1:
/usr/include/x86_64-linux-gnu/bits/mathcalls.h:250:1: note: previous declaration 'double y0(double)'
 __MATHCALL (y0,, (_Mdouble_));
 ^
aliens.cpp: In function 'int main()':
aliens.cpp:21:29: warning: format '%i' expects argument of type 'int*', but argument 4 has type 'double (*)(double) throw ()' [-Wformat=]
  scanf("%i %i %i",&n,&x0,&y0);
                          ~~~^
aliens.cpp:24:14: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
  for(mi=lo+hi+1>>1;lo<hi;mi=lo+hi+1>>1)
         ~~~~~^~
aliens.cpp:24:34: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
  for(mi=lo+hi+1>>1;lo<hi;mi=lo+hi+1>>1)
                             ~~~~~^~
aliens.cpp:26:18: error: invalid conversion from 'double (*)(double) throw ()' to 'int' [-fpermissive]
   if(Ask(x0+mi,y0)) lo=mi;
                  ^
aliens.cpp:4:5: note:   initializing argument 2 of 'int Ask(int, int)'
 int Ask(int x, int y)
     ^~~
aliens.cpp:30:5: error: invalid conversion from 'double (*)(double) throw ()' to 'int' [-fpermissive]
  hi=y0,lo=0;
     ^~
aliens.cpp:31:14: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
  for(mi=lo+hi+1>>1;lo<hi;mi=lo+hi+1>>1)
         ~~~~~^~
aliens.cpp:31:34: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
  for(mi=lo+hi+1>>1;lo<hi;mi=lo+hi+1>>1)
                             ~~~~~^~
aliens.cpp:33:15: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   if(Ask(x0,y0-mi)) lo=mi;
             ~~^~~
aliens.cpp:33:15: error: invalid conversion from 'double (*)(double) throw ()' to 'int' [-fpermissive]
aliens.cpp:4:5: note:   initializing argument 2 of 'int Ask(int, int)'
 int Ask(int x, int y)
     ^~~
aliens.cpp:36:4: warning: pointer to a function used in arithmetic [-Wpointer-arith]
  y0-=lo;
  ~~^~~~
aliens.cpp:36:6: error: assignment of read-only location 'y0'
  y0-=lo;
      ^~
aliens.cpp:36:6: error: cannot convert 'double (*)(double) throw ()' to 'double(double) throw ()' in assignment
aliens.cpp:37:16: error: no matching function for call to 'min(int, double (&)(double) throw ())'
  hi=min(n-x0,y0),lo=0;
                ^
In file included from /usr/include/c++/7/bits/char_traits.h:39:0,
                 from /usr/include/c++/7/ios:40,
                 from /usr/include/c++/7/istream:38,
                 from /usr/include/c++/7/sstream:38,
                 from /usr/include/c++/7/complex:45,
                 from /usr/include/c++/7/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52,
                 from aliens.cpp:1:
/usr/include/c++/7/bits/stl_algobase.h:195:5: note: candidate: template<class _Tp> const _Tp& std::min(const _Tp&, const _Tp&)
     min(const _Tp& __a, const _Tp& __b)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:195:5: note:   template argument deduction/substitution failed:
aliens.cpp:37:16: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'double(double) throw ()')
  hi=min(n-x0,y0),lo=0;
                ^
In file included from /usr/include/c++/7/bits/char_traits.h:39:0,
                 from /usr/include/c++/7/ios:40,
                 from /usr/include/c++/7/istream:38,
                 from /usr/include/c++/7/sstream:38,
                 from /usr/include/c++/7/complex:45,
                 from /usr/include/c++/7/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52,
                 from aliens.cpp:1:
/usr/include/c++/7/bits/stl_algobase.h:243:5: note: candidate: template<class _Tp, class _Compare> const _Tp& std::min(const _Tp&, const _Tp&, _Compare)
     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:243:5: note:   template argument deduction/substitution failed:
aliens.cpp:37:16: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'double(double) throw ()')
  hi=min(n-x0,y0),lo=0;
                ^
In file included from /usr/include/c++/7/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65,
                 from aliens.cpp:1:
/usr/include/c++/7/bits/stl_algo.h:3450:5: note: candidate: template<class _Tp> _Tp std::min(std::initializer_list<_Tp>)
     min(initializer_list<_Tp> __l)
     ^~~
/usr/include/c++/7/bits/stl_algo.h:3450:5: note:   template argument deduction/substitution failed:
aliens.cpp:37:16: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
  hi=min(n-x0,y0),lo=0;
                ^
In file included from /usr/include/c++/7/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65,
                 from aliens.cpp:1:
/usr/include/c++/7/bits/stl_algo.h:3456:5: note: candidate: template<class _Tp, class _Compare> _Tp std::min(std::initializer_list<_Tp>, _Compare)
     min(initializer_list<_Tp> __l, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algo.h:3456:5: note:   template argument deduction/substitution failed:
aliens.cpp:37:16: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
  hi=min(n-x0,y0),lo=0;
                ^
aliens.cpp:38:14: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
  for(mi=lo+hi+1>>1;lo<hi;mi=lo+hi+1>>1)
         ~~~~~^~
aliens.cpp:38:34: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
  for(mi=lo+hi+1>>1;lo<hi;mi=lo+hi+1>>1)
                             ~~~~~^~
aliens.cpp:40:18: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   if(Ask(x0+mi,y0-mi)) lo=mi;
                ~~^~~
aliens.cpp:40:18: error: invalid conversion from 'double (*)(double) throw ()' to 'int' [-fpermissive]
aliens.cpp:4:5: note:   initializing argument 2 of 'int Ask(int, int)'
 int Ask(int x, int y)
     ^~~
aliens.cpp:43:11: warning: pointer to a function used in arithmetic [-Wpointer-arith]
  x0+=lo;y0-=lo;
         ~~^~~~
aliens.cpp:43:13: error: assignment of read-only location 'y0'
  x0+=lo;y0-=lo;
             ^~
aliens.cpp:43:13: error: cannot convert 'double (*)(double) throw ()' to 'double(double) throw ()' in assignment
aliens.cpp:44:13: error: invalid operands of types 'int' and 'double(double) throw ()' to binary 'operator-'
  hi=min(x0,n-y0),lo=0;
            ~^~~
aliens.cpp:45:14: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
  for(mi=lo+hi+1>>1;lo<hi;mi=lo+hi+1>>1)
         ~~~~~^~
aliens.cpp:45:34: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
  for(mi=lo+hi+1>>1;lo<hi;mi=lo+hi+1>>1)
                             ~~~~~^~
aliens.cpp:47:18: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   if(Ask(x0-mi,y0+mi)) lo=mi;
                ~~^~~
aliens.cpp:47:18: error: invalid conversion from 'double (*)(double) throw ()' to 'int' [-fpermissive]
aliens.cpp:4:5: note:   initializing argument 2 of 'int Ask(int, int)'
 int Ask(int x, int y)
     ^~~
aliens.cpp:50:20: warning: pointer to a function used in arithmetic [-Wpointer-arith]
  int x1=x0-lo,y1=y0+lo;
                  ~~^~~
aliens.cpp:50:20: error: invalid conversion from 'double (*)(double) throw ()' to 'int' [-fpermissive]
aliens.cpp:52:27: warning: pointer to a function used in arithmetic [-Wpointer-arith]
  if(len%5==0 && !Ask(x0,y0-len/5))
                         ~~^~~~~~
aliens.cpp:52:27: error: invalid conversion from 'double (*)(double) throw ()' to 'int' [-fpermissive]
aliens.cpp:4:5: note:   initializing argument 2 of 'int Ask(int, int)'
 int Ask(int x, int y)
     ^~~
aliens.cpp:54:28: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   int x2=x0-(len-1)/2,y2=y0+(len-1)/2;
                          ~~^~~~~~~~~~
aliens.cpp:54:28: error: invalid conversion from 'double (*)(double) throw ()' to 'int' [-fpermissive]
aliens.cpp:57:32: warning: pointer to a function used in arithmetic [-Wpointer-arith]
  else if(len%3==0 && !Ask(x0,y0-len/3))
                              ~~^~~~~~
aliens.cpp:57:32: error: invalid conversion from 'double (*)(double) throw ()' to 'int' [-fpermissive]
aliens.cpp:4:5: note:   initializing argument 2 of 'int Ask(int, int)'
 int Ask(int x, int y)
     ^~~
aliens.cpp:61:19: error: invalid conversion from 'double (*)(double) throw ()' to 'int' [-fpermissive]
   if(Ask(x0+2*m,y0))
                   ^
aliens.cpp:4:5: note:   initializing argument 2 of 'int Ask(int, int)'
 int Ask(int x, int y)
     ^~~
aliens.cpp:63:27: warning: pointer to a function used in arithmetic [-Wpointer-arith]
    int x2=x0-(m-1)/2,y2=y0+(len-1)/2;
                         ~~^~~~~~~~~~
aliens.cpp:63:27: error: invalid conversion from 'double (*)(double) throw ()' to 'int' [-fpermissive]
aliens.cpp:68:29: warning: pointer to a function used in arithmetic [-Wpointer-arith]
    int x2=x0-(len-1)/2,y2=y0+(m-1)/2;
                           ~~^~~~~~~~
aliens.cpp:68:29: error: invalid conversion from 'double (*)(double) throw ()' to 'int' [-fpermissive]
aliens.cpp:76:19: error: invalid conversion from 'double (*)(double) throw ()' to 'int' [-fpermissive]
   if(Ask(x0+2*m,y0))
                   ^
aliens.cpp:4:5: note:   initializing argument 2 of 'int Ask(int, int)'
 int Ask(int x, int y)
     ^~~
aliens.cpp:78:33: warning: pointer to a function used in arithmetic [-Wpointer-arith]
    int x2=x0-m+1+(len-1)/2,y2=y0+(len-1)/2;
                               ~~^~~~~~~~~~
aliens.cpp:78:33: error: invalid conversion from 'double (*)(double) throw ()' to 'int' [-fpermissive]
aliens.cpp:83:29: warning: pointer to a function used in arithmetic [-Wpointer-arith]
    int x2=x0-(len-1)/2,y2=y0+m-1-(len-1)/2;
                           ~~^~
aliens.cpp:83:31: warning: pointer to a function used in arithmetic [-Wpointer-arith]
    int x2=x0-(len-1)/2,y2=y0+m-1-(len-1)/2;
                           ~~~~^~
aliens.cpp:83:33: warning: pointer to a function used in arithmetic [-Wpointer-arith]
    int x2=x0-(len-1)/2,y2=y0+m-1-(len-1)/2;
                           ~~~~~~^~~~~~~~~~
aliens.cpp:83:33: error: invalid conversion from 'double (*)(double) throw ()' to 'int' [-fpermissive]
aliens.cpp:50:6: warning: unused variable 'x1' [-Wunused-variable]
  int x1=x0-lo,y1=y0+lo;
      ^~
aliens.cpp:50:15: warning: unused variable 'y1' [-Wunused-variable]
  int x1=x0-lo,y1=y0+lo;
               ^~
aliens.cpp: In function 'int Ask(int, int)':
aliens.cpp:10: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:21: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);
  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~