Submission #90187

# Submission time Handle Problem Language Result Execution time Memory
90187 2018-12-20T18:51:03 Z asifthegreat Aliens (IOI07_aliens) C++14
0 / 100
2 ms 452 KB
#include <bits/stdc++.h>
using namespace std;

#define debug(a) cout << #a << " = " << a << endl;
#define int long long 

bool check(int x,int y);

bool check(int x,int y)
{
	printf("examine %lld %lld\n",x,y);
	fflush(stdout);
	char s[100];
	scanf("%s",s);
	if(!strcmp(s,"true"))return true;
	return false;
}


int32_t main()
{
	int n,m;
	scanf("%lld %lld ",&n,&m);
	int x,y;
	scanf("%lld %lld",&x,&y);
	int lo = y,hi = y+m;
	int dan = -1,bam=-1,upore=-1,niche=-1;
	while(hi-lo > 2){
		int mid=(lo+hi)/2;
		if(check(x,mid)){
			dan = max(dan,mid);
			lo = mid+1;
		}
		else hi = mid-1;
	}
	for(int mid = lo;mid <= hi;mid++){
		if(check(x,mid)){
			dan = max(dan,mid);
		}
	}
	if(dan+m*4 <= n and check(x,dan+m*4)){
		dan = dan+m*4;
	}
	else if(dan + m* 2 <= n and check(x,dan+m*2))dan = dan+m*2;
	lo = max(1ll,y-m);
	hi = y;
	bam = y;
	while(hi-lo > 2){
		int mid=(lo+hi)/2;
		if(check(x,mid)){
			bam = min(bam,mid);
			hi = mid-1;
		}
		else lo = mid+1;
	}
	for(int mid = lo;mid <= hi;mid++){
		if(check(x,mid)){
			bam = min(bam,mid);
		}
	}
	if(bam-m*4 > 0 and check(x,bam-m*4)){
		bam -= m*4;
	}
	else if(bam-m*2 > 0 and check(x,bam-m*2)){
		bam -= m*2;
	}
	hi = x;
	lo = max(1ll,x-m);
	upore = x;
	while(hi-lo > 2){
		int mid=(lo+hi)/2;
		if(check(mid,y)){
			upore = min(upore,mid);
			hi = mid-1;
		}
		else lo = mid+1;
	}
	for(int mid = lo;mid <= hi;mid++){
		if(check(mid,y)){
			upore = min(upore,mid);
		}
	}
	if(upore-m*4 > 0 and check(upore-m*4,y)){
		upore -= m*4;
	}
	else if(upore-m*2 > 0 and check(upore-m*2,y)){
		upore -= m*2;
	}
	niche = x;
	lo = x;
	hi = x+m;
	while(hi-lo > 2){
		int mid=(lo+hi)/2;
		if(check(mid,y)){
			niche = max(niche,mid);
			lo = mid+1;
		}
		else hi = mid-1;
	}
	for(int mid = lo;mid <= hi;mid++){
		if(check(mid,y)){
			niche = max(niche,mid);
		}
	}
	if(niche+m*4 <= n and check(niche+m*4,y)){
		niche = niche+m*4;
	}
	else if(niche + m* 2 <= n and check(niche+m*2,y))niche = niche+m*2;
	x = (niche-upore)/2 + m;
	y = (dan-bam)/2 + m;
	printf("%lld %lld\n",x,y);
	return 0;
}

Compilation message

aliens.cpp: In function 'bool check(long long int, long long int)':
aliens.cpp:14:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%s",s);
  ~~~~~^~~~~~~~
aliens.cpp: In function 'int32_t main()':
aliens.cpp:23:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld %lld ",&n,&m);
  ~~~~~^~~~~~~~~~~~~~~~~~~~
aliens.cpp:25:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld %lld",&x,&y);
  ~~~~~^~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Execution timed out 2 ms 248 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2 ms 332 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2 ms 372 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1 ms 372 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2 ms 372 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2 ms 372 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2 ms 452 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2 ms 452 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2 ms 452 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1 ms 452 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -