답안 #233863

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
233863 2020-05-22T05:09:49 Z T0p_ Aliens (IOI07_aliens) C++14
0 / 100
5 ms 384 KB
#include<bits/stdc++.h>
using namespace std;

bool examine(int a, int b)
{
	printf("%d %d\n",a,b);
	fflush(stdout);
	int ret;
	scanf(" %d",&ret);
	return ret;
}

void solution(int a, int b)
{
	printf("%d %d\n",a,b);
	fflush(stdout);
}

int main()
{
	long long n, x, y, l, r, L, R, T, B, sz;
	scanf(" %lld %lld %lld",&n,&x,&y);

	//right
	l = x, r = n;
	while(l != r)
	{
		long long mid = (l+r+1)>>1ll;
		if(!examine(mid, y)) r = mid-1;
		else if(!examine((l+mid)>>1ll, y)) r = mid-1;
		else if(!examine((l+((l+mid)>>1ll))>>1ll, y)) r = mid-1;
		else l = mid;
	}
	R = l;

	//left
	l = 1, r = x;
	while(l != r)
	{
		long long mid = (l+r)>>1ll;
		if(!examine(mid, y)) l = mid+1;
		else if(!examine((mid+r)>>1ll, y)) l = mid+1;
		else if(!examine((((mid+r)>>1ll)+r)>>1ll, y)) l = mid+1;
		else r = mid;
	}
	L = l;

	//top
	l = y, r = n;
	while(l != r)
	{
		long long mid = (l+r+1)>>1ll;
		if(!examine(x, mid)) r = mid-1;
		else if(!examine(x, (l+mid)>>1ll)) r = mid-1;
		else if(!examine(x, (l+((l+mid)>>1ll))>>1ll)) r = mid-1;
		else l = mid;
	}
	T = l;

	sz = R-L+1;
	B = T-sz+1;
	long long mx = (L+R)>>1ll, my = (B+T)>>1ll;
	int tl = 0, tr = 0, bl = 0, br = 0;
	for(int i=1 ; i<=4 ; i++)
	{
		if(mx - i*sz >= 1 && my + i*sz <= n && examine(mx-i*sz, my+i*sz)) tl++;
		if(mx + i*sz <= n && my + i*sz <= n && examine(mx+i*sz, my+i*sz)) tr++;
		if(mx - i*sz >= 1 && my - i*sz >= 1 && examine(mx-i*sz, my-i*sz)) bl++;
		if(mx + i*sz <= n && my - i*sz >= 1 && examine(mx+i*sz, my-i*sz)) br++;
	}
	if(tl == 0)
	{
		if(tr == 4) solution(mx+2*sz, my+2*sz);
		else if(bl == 4) solution(mx-2*sz, my-2*sz);
		else if(br == 4) solution(mx+2*sz, my-2*sz);
		else if(tr == 2) solution(mx+sz, my);
		else solution(mx, my-sz);
	}
	else if(tl == 1)
	{
		if(tr == 3) solution(mx+sz, my+sz);
		else if(bl == 3) solution(mx-sz, my-sz);
		else solution(mx+sz, my-sz);
	}
	else if(tl == 2)
	{
		if(bl + br == 0) solution(mx, my+sz);
		else if(bl + br == 2) solution(mx-sz, my);
		else solution(mx, my);
	}
	else if(tl == 3) solution(mx-sz, my+sz);
	else solution(mx-2*sz, my+2*sz);
	return 0;
}

Compilation message

aliens.cpp: In function 'bool examine(int, int)':
aliens.cpp:9:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf(" %d",&ret);
  ~~~~~^~~~~~~~~~~~
aliens.cpp: In function 'int main()':
aliens.cpp:22:7: 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 Execution timed out 4 ms 256 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 5 ms 384 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 4 ms 256 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 5 ms 384 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 5 ms 256 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 4 ms 256 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 5 ms 384 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 4 ms 256 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 5 ms 384 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 5 ms 384 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -