답안 #80090

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
80090 2018-10-19T01:28:01 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 x1,y1;
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",&x1,&y1);
	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(x1,y1+len)||!examine(x1,y1+len)) {
			D=len;
			ll l=0,r=D;
			ll mid=0;
			ll ans=0;
			while (l<=r) {
				mid=(l+r)/2;
				if (!ok(x1,y1+mid)||!examine(x1,y1+mid)) {
					r=mid-1;
				} else {
					ans=mid;
					l=mid+1;
				} 
			}
			y[1]=y1+ans;
			break;
		} 
	}
	len=0,D=0,f=0;
	for (int i=0;i<32;i++) {
		len+=bin[i];
		if (!ok(x1,y1-len)||!examine(x1,y1-len)) {
			D=len;
			ll l=0,r=D;
			ll mid=0;
			ll ans=0;
			while (l<=r) {
				mid=(l+r)/2;
				if (!ok(x1,y1-mid)||!examine(x1,y1-mid)) {
					r=mid-1;
				} else {
					ans=mid;
					l=mid+1;
				} 
			}
			y[0]=y1-ans;
			break;
		} 
	}
	len=0,D=0,f=0;
	for (int i=0;i<32;i++) {
		len+=bin[i];
		if (!ok(x1+len,y1)||!examine(x1+len,y1)) {
			D=len;
			ll l=0,r=D;
			ll mid=0;
			ll ans=0;
			while (l<=r) {
				mid=(l+r)/2;
				if (!ok(x1+mid,y1)||!examine(x1+mid,y1)) {
					r=mid-1;
				} else {
					ans=mid;
					l=mid+1;
				} 
			}
			x[1]=x1+ans;
			break;
		} 
	}
	m=y[1]-y[0]+1;
	x[0]=y[0]+x[1]-y[1];
	x1=x[0]+m/2,y1=y[0]+m/2;
	
	/*
	cout<<x[0]<<" "<<x[1]<<" "<<y[0]<<" "<<y[1]<<endl;
	cout<<x1<<" "<<y1<<" "<<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(x1,y1+2*m*mid)||!examine(x1,y1+2*m*mid)) {
			r=mid-1;
		} else {
			ans=mid;
			l=mid+1;
		}
		y[1]=y1+2*m*ans;
	}
	l=0,r=n/(2*m);
	mid=0;
	ans=0;
	while (l<=r) {
		mid=(l+r)/2;
		if (!ok(x1,y1-2*m*mid)||!examine(x1,y1-2*m*mid)) {
			r=mid-1;
		} else {
			ans=mid;
			l=mid+1;
		}
		y[0]=y1-2*m*ans;
	}
	l=0,r=n/(2*m);
	mid=0;
	ans=0;
	while (l<=r) {
		mid=(l+r)/2;
		if (!ok(x1+2*m*mid,y1)||!examine(x1+2*m*mid,y1)) {
			r=mid-1;
		} else {
			ans=mid;
			l=mid+1;
		}
		x[1]=x1+2*m*ans;
	}
	l=0,r=n/(2*m);
	mid=0;
	ans=0;
	while (l<=r) {
		mid=(l+r)/2;
		if (!ok(x1-2*m*mid,y1)||!examine(x1-2*m*mid,y1)) {
			r=mid-1;
		} else {
			ans=mid;
			l=mid+1;
		}
		x[0]=x1-2*m*ans;
	}
	x1=x[0]+x[1],x1/=2;
	y1=y[0]+y[1],y1/=2;
	cout<<"solution "<<x1<<" "<<y1<<endl;
	return 0;
}

Compilation message

aliens.cpp:22:7: error: 'll y1' redeclared as different kind of symbol
 ll x1,y1;
       ^~
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:251:1: note: previous declaration 'double y1(double)'
 __MATHCALL (y1,, (_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",&x1,&y1);
                        ~~~^
aliens.cpp:54:16: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   if (!ok(x1,y1+len)||!examine(x1,y1+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(x1,y1+len)||!examine(x1,y1+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(x1,y1+mid)||!examine(x1,y1+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(x1,y1+mid)||!examine(x1,y1+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]=y1+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(x1,y1-len)||!examine(x1,y1-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(x1,y1-len)||!examine(x1,y1-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(x1,y1-mid)||!examine(x1,y1-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(x1,y1-mid)||!examine(x1,y1-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]=y1-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(x1+len,y1)||!examine(x1+len,y1)) {
                    ^
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(x1+len,y1)||!examine(x1+len,y1)) {
                                         ^
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(x1+mid,y1)||!examine(x1+mid,y1)) {
                      ^
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(x1+mid,y1)||!examine(x1+mid,y1)) {
                                           ^
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 y1(double)'
  x1=x[0]+m/2,y1=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(x1,y1+2*m*mid)||!examine(x1,y1+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(x1,y1+2*m*mid)||!examine(x1,y1+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]=y1+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(x1,y1-2*m*mid)||!examine(x1,y1-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(x1,y1-2*m*mid)||!examine(x1,y1-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]=y1-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(x1+2*m*mid,y1)||!examine(x1+2*m*mid,y1)) {
                        ^
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(x1+2*m*mid,y1)||!examine(x1+2*m*mid,y1)) {
                                                 ^
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(x1-2*m*mid,y1)||!examine(x1-2*m*mid,y1)) {
                        ^
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(x1-2*m*mid,y1)||!examine(x1-2*m*mid,y1)) {
                                                 ^
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 y1(double)'
  y1=y[0]+y[1],y1/=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/'
  y1=y[0]+y[1],y1/=2;
               ~~^~~
aliens.cpp:178:19: error:   in evaluation of 'operator/=(double(double) throw (), int)'
  y1=y[0]+y[1],y1/=2;
                   ^
aliens.cpp:179:30: warning: the address of 'double y1(double)' will never be NULL [-Waddress]
  cout<<"solution "<<x1<<" "<<y1<<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",&x1,&y1);
  ~~~~~^~~~~~~~~~~~~~~~~~~~~