Submission #233867

# Submission time Handle Problem Language Result Execution time Memory
233867 2020-05-22T05:18:19 Z T0p_ Aliens (IOI07_aliens) C++14
40 / 100
7 ms 384 KB
#include<bits/stdc++.h>
using namespace std;

map<pair<int, int>, int> mic;

bool examine(long long a, long long b)
{
	if(mic[{a, b}] == 1) return true;
	else if(mic[{a, b}] == -1) return false;
	printf("examine %lld %lld\n",a,b);
	fflush(stdout);
	char str[7];
	scanf(" %s",str);
	mic[{a, b}] = (str[0] == 't') ? 1 : -1;
	return (str[0] == 't') ? true : false;
}

void solution(long long a, long long b)
{
	printf("solution %lld %lld\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(long long int, long long int)':
aliens.cpp:13:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf(" %s",str);
  ~~~~~^~~~~~~~~~~
aliens.cpp: In function 'int main()':
aliens.cpp:27: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);
  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 384 KB Incorrect
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 256 KB Incorrect
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 6 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 256 KB Incorrect
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 6 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 256 KB Incorrect
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 256 KB Incorrect
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 6 ms 384 KB Output is correct
2 Incorrect 7 ms 384 KB Incorrect
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 372 KB Output is correct
3 Correct 7 ms 384 KB Output is correct