답안 #77140

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
77140 2018-09-22T18:51:04 Z doowey Aliens (IOI07_aliens) C++14
100 / 100
5 ms 548 KB
    #include <bits/stdc++.h>
    using namespace std;
     
    #define int long long
    int N, M, x, y, i, d, a, lo, hi;
    string inp;
    bool get(int x,int y){
    	printf("examine %d %d\n",(signed)x,(signed)y);
    	fflush(stdout);
    	cin >> inp;
    	return inp == "true";
    }
    signed main(){
    	scanf("%lld%lld%lld",&N,&x,&y);
    	for(i=0;x+(1LL<<i)<=N;i++){
    		if(!get(x+(1LL<<i),y)) break;
    	}
    	lo = 1, hi = 1LL<<i;
    	while(lo<hi){
    		int m=lo+hi>>1;
    		if(!get(x+m,y)) hi=m;
    		else lo=m+1;
    	}
    	lo--; d = lo; a = 0;
    	for(i=0;x-(1LL<<i)>=1;i++){
    		if(!get(x-(1LL<<i),y)) break;
    	}
    	lo = 1, hi = 1LL<<i;
    	while(lo<hi){
    		int m=lo+hi>>1;
    		if(!get(x-m,y)) hi=m;
    		else lo=m+1;
    	}
    	lo--; M = 1+lo+d; a=0;
    	x += (M/2)-lo;
    	for(i=0;y+(1LL<<i)<=N;i++){
    		if(!get(x,y+(1LL<<i))) break;
    	}
    	lo = 1, hi = 1LL<<i;
    	while(lo<hi){
    		int m=lo+hi>>1;
    		if(!get(x,y+m)) hi=m;
    		else lo=m+1;
    	}
    	lo--; y -= (M/2)-lo;
    	int l=0, r=0, u=0, d=0;
    	for(i=1;2*M*i+x<=N;i++){
    		if(!get(x+2*M*i,y)) break;
    	}
    	r = i-1;
    	for(i=1;x-2*M*i>=1;i++){
    		if(!get(x-2*M*i,y)) break;
    	}
    	l = i-1;
    	for(i=1;y+2*M*i<=N;i++){
    		if(!get(x,y+2*M*i)) break;
    	}
    	u = i-1;
    	for(i=1;y-2*M*i>=1;i++){
    		if(!get(x,y-2*M*i)) break;
    	}
    	d = i-1;
    	if(l+r==1){
    		if(!r) x -= M;
    		else x += M;
    		if(!u) y -= M;
    		else y += M;
    	}
    	else{
    		x += 2*M*(r-1);
    		y += 2*M*(u-1);
    	}
    	printf("solution %d %d\n",(signed)x,(signed)y);
    	fflush(stdout);
    	return 0;
    }//19 5 16

Compilation message

aliens.cpp: In function 'int main()':
aliens.cpp:20:15: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
       int m=lo+hi>>1;
             ~~^~~
aliens.cpp:30:15: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
       int m=lo+hi>>1;
             ~~^~~
aliens.cpp:41:15: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
       int m=lo+hi>>1;
             ~~^~~
aliens.cpp:46:25: warning: variable 'd' set but not used [-Wunused-but-set-variable]
      int l=0, r=0, u=0, d=0;
                         ^
aliens.cpp:14:11: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
      scanf("%lld%lld%lld",&N,&x,&y);
      ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 452 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 452 KB Output is correct
2 Correct 3 ms 452 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 452 KB Output is correct
2 Correct 2 ms 452 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 460 KB Output is correct
2 Correct 2 ms 488 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 488 KB Output is correct
2 Correct 2 ms 488 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 488 KB Output is correct
2 Correct 2 ms 488 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 548 KB Output is correct
2 Correct 2 ms 548 KB Output is correct
3 Correct 2 ms 548 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 548 KB Output is correct
2 Correct 2 ms 548 KB Output is correct
3 Correct 5 ms 548 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 548 KB Output is correct
2 Correct 4 ms 548 KB Output is correct
3 Correct 2 ms 548 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 548 KB Output is correct
2 Correct 3 ms 548 KB Output is correct
3 Correct 2 ms 548 KB Output is correct