답안 #80089

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
80089 2018-10-19T01:25:46 Z AngelKnows Aliens (IOI07_aliens) C++14
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for (int i=1;i<=n;i++)
#define REP(i,a,b) for (int i=a;i<=b;i++)
 
#define pb push_back
#define fi first
#define se second
#define pi pair<int,int>
#define mp make_pair
#define sz(x) ((int)(x).size())
 
typedef long long ll;

const int inf=0x3f3f3f3f;
const ll linf=1e18;
const int N=300000+10;
const double eps=1e-5;
const int mo=1e9+7;

ll n,m;
ll x0,y0;
ll x[2],y[2];
ll bin[40];
char word[10];
bool ok(ll x,ll y) {
	return 1<=x&&x<=n&&1<=y&&y<=n;
}
bool examine(ll x,ll y) {
	printf("examine %lld %lld\n",x,y);
	fflush(stdout);
	scanf("%s",&word);
	if (word[0]=='t') return 1;
	else return 0;
}
int main() {
 
    std::ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    scanf("%lld",&n);
	scanf("%lld %lld",&x0,&y0);
	bin[0]=1;
	FOR(i,32) bin[i]=bin[i-1]*2;
	ll len=0,D=0;
	int f=0;
	
	len=0,D=0,f=0;
	for (int i=0;i<32;i++) {
		len+=bin[i];
		if (!ok(x0,y0+len)||!examine(x0,y0+len)) {
			D=len;
			ll l=0,r=D;
			ll mid=0;
			ll ans=0;
			while (l<=r) {
				mid=(l+r)/2;
				if (!ok(x0,y0+mid)||!examine(x0,y0+mid)) {
					r=mid-1;
				} else {
					ans=mid;
					l=mid+1;
				} 
			}
			y[1]=y0+ans;
			break;
		} 
	}
	len=0,D=0,f=0;
	for (int i=0;i<32;i++) {
		len+=bin[i];
		if (!ok(x0,y0-len)||!examine(x0,y0-len)) {
			D=len;
			ll l=0,r=D;
			ll mid=0;
			ll ans=0;
			while (l<=r) {
				mid=(l+r)/2;
				if (!ok(x0,y0-mid)||!examine(x0,y0-mid)) {
					r=mid-1;
				} else {
					ans=mid;
					l=mid+1;
				} 
			}
			y[0]=y0-ans;
			break;
		} 
	}
	len=0,D=0,f=0;
	for (int i=0;i<32;i++) {
		len+=bin[i];
		if (!ok(x0+len,y0)||!examine(x0+len,y0)) {
			D=len;
			ll l=0,r=D;
			ll mid=0;
			ll ans=0;
			while (l<=r) {
				mid=(l+r)/2;
				if (!ok(x0+mid,y0)||!examine(x0+mid,y0)) {
					r=mid-1;
				} else {
					ans=mid;
					l=mid+1;
				} 
			}
			x[1]=x0+ans;
			break;
		} 
	}
	m=y[1]-y[0]+1;
	x[0]=y[0]+x[1]-y[1];
	x0=x[0]+m/2,y0=y[0]+m/2;
	
	/*
	cout<<x[0]<<" "<<x[1]<<" "<<y[0]<<" "<<y[1]<<endl;
	cout<<x0<<" "<<y0<<" "<<m<<endl;
	*/
	
	ll l,r,mid,ans;
	
	l=0,r=n/(2*m);
	mid=0;
	ans=0;
	while (l<=r) {
		mid=(l+r)/2;
		if (!ok(x0,y0+2*m*mid)||!examine(x0,y0+2*m*mid)) {
			r=mid-1;
		} else {
			ans=mid;
			l=mid+1;
		}
		y[1]=y0+2*m*ans;
	}
	l=0,r=n/(2*m);
	mid=0;
	ans=0;
	while (l<=r) {
		mid=(l+r)/2;
		if (!ok(x0,y0-2*m*mid)||!examine(x0,y0-2*m*mid)) {
			r=mid-1;
		} else {
			ans=mid;
			l=mid+1;
		}
		y[0]=y0-2*m*ans;
	}
	l=0,r=n/(2*m);
	mid=0;
	ans=0;
	while (l<=r) {
		mid=(l+r)/2;
		if (!ok(x0+2*m*mid,y0)||!examine(x0+2*m*mid,y0)) {
			r=mid-1;
		} else {
			ans=mid;
			l=mid+1;
		}
		x[1]=x0+2*m*ans;
	}
	l=0,r=n/(2*m);
	mid=0;
	ans=0;
	while (l<=r) {
		mid=(l+r)/2;
		if (!ok(x0-2*m*mid,y0)||!examine(x0-2*m*mid,y0)) {
			r=mid-1;
		} else {
			ans=mid;
			l=mid+1;
		}
		x[0]=x0-2*m*ans;
	}
	x0=x[0]+x[1],x0/=2;
	y0=y[0]+y[1],y0/=2;
	cout<<x0<<" "<<y0<<endl;
	return 0;
}

Compilation message

aliens.cpp:22:7: error: 'll y0' redeclared as different kind of symbol
 ll 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 'bool examine(ll, ll)':
aliens.cpp:32:18: warning: format '%s' expects argument of type 'char*', but argument 2 has type 'char (*)[10]' [-Wformat=]
  scanf("%s",&word);
             ~~~~~^
aliens.cpp: In function 'int main()':
aliens.cpp:45:27: warning: format '%lld' expects argument of type 'long long int*', but argument 3 has type 'double (*)(double) throw ()' [-Wformat=]
  scanf("%lld %lld",&x0,&y0);
                        ~~~^
aliens.cpp:54:16: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   if (!ok(x0,y0+len)||!examine(x0,y0+len)) {
              ~~^~~~
aliens.cpp:54:16: error: invalid conversion from 'double (*)(double) throw ()' to 'll {aka long long int}' [-fpermissive]
aliens.cpp:26:6: note:   initializing argument 2 of 'bool ok(ll, ll)'
 bool ok(ll x,ll y) {
      ^~
aliens.cpp:54:37: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   if (!ok(x0,y0+len)||!examine(x0,y0+len)) {
                                   ~~^~~~
aliens.cpp:54:37: error: invalid conversion from 'double (*)(double) throw ()' to 'll {aka long long int}' [-fpermissive]
aliens.cpp:29:6: note:   initializing argument 2 of 'bool examine(ll, ll)'
 bool examine(ll x,ll y) {
      ^~~~~~~
aliens.cpp:61:18: warning: pointer to a function used in arithmetic [-Wpointer-arith]
     if (!ok(x0,y0+mid)||!examine(x0,y0+mid)) {
                ~~^~~~
aliens.cpp:61:18: error: invalid conversion from 'double (*)(double) throw ()' to 'll {aka long long int}' [-fpermissive]
aliens.cpp:26:6: note:   initializing argument 2 of 'bool ok(ll, ll)'
 bool ok(ll x,ll y) {
      ^~
aliens.cpp:61:39: warning: pointer to a function used in arithmetic [-Wpointer-arith]
     if (!ok(x0,y0+mid)||!examine(x0,y0+mid)) {
                                     ~~^~~~
aliens.cpp:61:39: error: invalid conversion from 'double (*)(double) throw ()' to 'll {aka long long int}' [-fpermissive]
aliens.cpp:29:6: note:   initializing argument 2 of 'bool examine(ll, ll)'
 bool examine(ll x,ll y) {
      ^~~~~~~
aliens.cpp:68:11: warning: pointer to a function used in arithmetic [-Wpointer-arith]
    y[1]=y0+ans;
         ~~^~~~
aliens.cpp:68:11: error: invalid conversion from 'double (*)(double) throw ()' to 'll {aka long long int}' [-fpermissive]
aliens.cpp:75:16: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   if (!ok(x0,y0-len)||!examine(x0,y0-len)) {
              ~~^~~~
aliens.cpp:75:16: error: invalid conversion from 'double (*)(double) throw ()' to 'll {aka long long int}' [-fpermissive]
aliens.cpp:26:6: note:   initializing argument 2 of 'bool ok(ll, ll)'
 bool ok(ll x,ll y) {
      ^~
aliens.cpp:75:37: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   if (!ok(x0,y0-len)||!examine(x0,y0-len)) {
                                   ~~^~~~
aliens.cpp:75:37: error: invalid conversion from 'double (*)(double) throw ()' to 'll {aka long long int}' [-fpermissive]
aliens.cpp:29:6: note:   initializing argument 2 of 'bool examine(ll, ll)'
 bool examine(ll x,ll y) {
      ^~~~~~~
aliens.cpp:82:18: warning: pointer to a function used in arithmetic [-Wpointer-arith]
     if (!ok(x0,y0-mid)||!examine(x0,y0-mid)) {
                ~~^~~~
aliens.cpp:82:18: error: invalid conversion from 'double (*)(double) throw ()' to 'll {aka long long int}' [-fpermissive]
aliens.cpp:26:6: note:   initializing argument 2 of 'bool ok(ll, ll)'
 bool ok(ll x,ll y) {
      ^~
aliens.cpp:82:39: warning: pointer to a function used in arithmetic [-Wpointer-arith]
     if (!ok(x0,y0-mid)||!examine(x0,y0-mid)) {
                                     ~~^~~~
aliens.cpp:82:39: error: invalid conversion from 'double (*)(double) throw ()' to 'll {aka long long int}' [-fpermissive]
aliens.cpp:29:6: note:   initializing argument 2 of 'bool examine(ll, ll)'
 bool examine(ll x,ll y) {
      ^~~~~~~
aliens.cpp:89:11: warning: pointer to a function used in arithmetic [-Wpointer-arith]
    y[0]=y0-ans;
         ~~^~~~
aliens.cpp:89:11: error: invalid conversion from 'double (*)(double) throw ()' to 'll {aka long long int}' [-fpermissive]
aliens.cpp:96:20: error: invalid conversion from 'double (*)(double) throw ()' to 'll {aka long long int}' [-fpermissive]
   if (!ok(x0+len,y0)||!examine(x0+len,y0)) {
                    ^
aliens.cpp:26:6: note:   initializing argument 2 of 'bool ok(ll, ll)'
 bool ok(ll x,ll y) {
      ^~
aliens.cpp:96:41: error: invalid conversion from 'double (*)(double) throw ()' to 'll {aka long long int}' [-fpermissive]
   if (!ok(x0+len,y0)||!examine(x0+len,y0)) {
                                         ^
aliens.cpp:29:6: note:   initializing argument 2 of 'bool examine(ll, ll)'
 bool examine(ll x,ll y) {
      ^~~~~~~
aliens.cpp:103:22: error: invalid conversion from 'double (*)(double) throw ()' to 'll {aka long long int}' [-fpermissive]
     if (!ok(x0+mid,y0)||!examine(x0+mid,y0)) {
                      ^
aliens.cpp:26:6: note:   initializing argument 2 of 'bool ok(ll, ll)'
 bool ok(ll x,ll y) {
      ^~
aliens.cpp:103:43: error: invalid conversion from 'double (*)(double) throw ()' to 'll {aka long long int}' [-fpermissive]
     if (!ok(x0+mid,y0)||!examine(x0+mid,y0)) {
                                           ^
aliens.cpp:29:6: note:   initializing argument 2 of 'bool examine(ll, ll)'
 bool examine(ll x,ll y) {
      ^~~~~~~
aliens.cpp:116:24: error: assignment of function 'double y0(double)'
  x0=x[0]+m/2,y0=y[0]+m/2;
                        ^
aliens.cpp:116:24: error: cannot convert 'll {aka long long int}' to 'double(double) throw ()' in assignment
aliens.cpp:130:16: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   if (!ok(x0,y0+2*m*mid)||!examine(x0,y0+2*m*mid)) {
              ~~^~~~~~~~
aliens.cpp:130:16: error: invalid conversion from 'double (*)(double) throw ()' to 'll {aka long long int}' [-fpermissive]
aliens.cpp:26:6: note:   initializing argument 2 of 'bool ok(ll, ll)'
 bool ok(ll x,ll y) {
      ^~
aliens.cpp:130:41: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   if (!ok(x0,y0+2*m*mid)||!examine(x0,y0+2*m*mid)) {
                                       ~~^~~~~~~~
aliens.cpp:130:41: error: invalid conversion from 'double (*)(double) throw ()' to 'll {aka long long int}' [-fpermissive]
aliens.cpp:29:6: note:   initializing argument 2 of 'bool examine(ll, ll)'
 bool examine(ll x,ll y) {
      ^~~~~~~
aliens.cpp:136:10: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   y[1]=y0+2*m*ans;
        ~~^~~~~~~~
aliens.cpp:136:10: error: invalid conversion from 'double (*)(double) throw ()' to 'll {aka long long int}' [-fpermissive]
aliens.cpp:143:16: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   if (!ok(x0,y0-2*m*mid)||!examine(x0,y0-2*m*mid)) {
              ~~^~~~~~~~
aliens.cpp:143:16: error: invalid conversion from 'double (*)(double) throw ()' to 'll {aka long long int}' [-fpermissive]
aliens.cpp:26:6: note:   initializing argument 2 of 'bool ok(ll, ll)'
 bool ok(ll x,ll y) {
      ^~
aliens.cpp:143:41: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   if (!ok(x0,y0-2*m*mid)||!examine(x0,y0-2*m*mid)) {
                                       ~~^~~~~~~~
aliens.cpp:143:41: error: invalid conversion from 'double (*)(double) throw ()' to 'll {aka long long int}' [-fpermissive]
aliens.cpp:29:6: note:   initializing argument 2 of 'bool examine(ll, ll)'
 bool examine(ll x,ll y) {
      ^~~~~~~
aliens.cpp:149:10: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   y[0]=y0-2*m*ans;
        ~~^~~~~~~~
aliens.cpp:149:10: error: invalid conversion from 'double (*)(double) throw ()' to 'll {aka long long int}' [-fpermissive]
aliens.cpp:156:24: error: invalid conversion from 'double (*)(double) throw ()' to 'll {aka long long int}' [-fpermissive]
   if (!ok(x0+2*m*mid,y0)||!examine(x0+2*m*mid,y0)) {
                        ^
aliens.cpp:26:6: note:   initializing argument 2 of 'bool ok(ll, ll)'
 bool ok(ll x,ll y) {
      ^~
aliens.cpp:156:49: error: invalid conversion from 'double (*)(double) throw ()' to 'll {aka long long int}' [-fpermissive]
   if (!ok(x0+2*m*mid,y0)||!examine(x0+2*m*mid,y0)) {
                                                 ^
aliens.cpp:29:6: note:   initializing argument 2 of 'bool examine(ll, ll)'
 bool examine(ll x,ll y) {
      ^~~~~~~
aliens.cpp:169:24: error: invalid conversion from 'double (*)(double) throw ()' to 'll {aka long long int}' [-fpermissive]
   if (!ok(x0-2*m*mid,y0)||!examine(x0-2*m*mid,y0)) {
                        ^
aliens.cpp:26:6: note:   initializing argument 2 of 'bool ok(ll, ll)'
 bool ok(ll x,ll y) {
      ^~
aliens.cpp:169:49: error: invalid conversion from 'double (*)(double) throw ()' to 'll {aka long long int}' [-fpermissive]
   if (!ok(x0-2*m*mid,y0)||!examine(x0-2*m*mid,y0)) {
                                                 ^
aliens.cpp:29:6: note:   initializing argument 2 of 'bool examine(ll, ll)'
 bool examine(ll x,ll y) {
      ^~~~~~~
aliens.cpp:178:13: error: assignment of function 'double y0(double)'
  y0=y[0]+y[1],y0/=2;
             ^
aliens.cpp:178:13: error: cannot convert 'll {aka long long int}' to 'double(double) throw ()' in assignment
aliens.cpp:178:17: error: invalid operands of types 'double(double) throw ()' and 'int' to binary 'operator/'
  y0=y[0]+y[1],y0/=2;
               ~~^~~
aliens.cpp:178:19: error:   in evaluation of 'operator/=(double(double) throw (), int)'
  y0=y[0]+y[1],y0/=2;
                   ^
aliens.cpp:179:17: warning: the address of 'double y0(double)' will never be NULL [-Waddress]
  cout<<x0<<" "<<y0<<endl;
                 ^~
aliens.cpp: In function 'bool examine(ll, ll)':
aliens.cpp:32:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%s",&word);
  ~~~~~^~~~~~~~~~~~
aliens.cpp: In function 'int main()':
aliens.cpp:44:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%lld",&n);
     ~~~~~^~~~~~~~~~~
aliens.cpp:45:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld %lld",&x0,&y0);
  ~~~~~^~~~~~~~~~~~~~~~~~~~~