답안 #123402

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
123402 2019-07-01T11:46:56 Z TuGSGeReL Aliens (IOI07_aliens) C++17
0 / 100
2 ms 376 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

#define ll long long
#define mp make_pair
#define pub push_back
#define pob pop_back()
#define ss second
#define ff first
#define mt make_tuple
#define pof pop_front()
#define fbo find_by_order
#define ook order_of_key
#define lb lower_bound
#define ub upper_bound

typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
using pll = pair <ll, ll>;
using pii = pair <int, int>;

int n, x, y, k = 1, rib, leb, upb, m;

bool examine(int a, int b)
{
	string bo;
	cout << "examine " << a << " " << b << "\n";
	cin >> bo;
	
	if ( bo == "true" )
		return 1;
	
	return 0;
}

int main ()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	
	cin >> n >> x >> y;

	if ( y < n )
	{
		while (examine(x, k + y))
		{
			k = k * 2;
			
			if ( k + y > n )
			{
				k = n - y;
				break;
			}
		}
	} else {
		k = 0;
	}
	
	int l = y, r = y + k;
	
	while (l + 1 < r)
	{
		int mid = (l + r) / 2;
		
		if ( examine(x, mid) )
			l = mid;
		
		else
			r = mid;
	}
	
	if ( examine(x, r) )
		rib = r;
	
	else
		rib = l;
	
	if ( y > 1 )
	{
		k = 1;
		while (examine(x, y - k))
		{
			k = k * 2;
			
			if ( x - k <= 0 )
			{
				k = y - 1;
				break;
			}
		}
	} else {
		k = 0;
	}
	
	l = y - k, r = y;
	
	while (l + 1 < r)
	{
		int mid = (l + r) / 2;
	
		if ( examine(x, mid) )
			r = mid;
		
		else
			l = mid;
	}
	
	if ( examine(x, l) )
		leb = l;
	
	else
		leb = r;
	
	m = rib - leb + 1;
	
	if ( x > 1 )
	{
		k = 1;
		while (examine(x - k, y))
		{
			k = k * 2;
			
			if ( x - k <= 0 )
			{
				k = x - 1;
				break;
			}
		}
	} else {
		k = 0;
	}
	
	l = x - k, r = x;
	
	while (l + 1 < r)
	{
		int mid = (l + r) / 2;
		
		if ( examine(mid, y) )
			r = mid;
		
		else
			l = mid;
	}
	
	if ( examine(l, y) )
		upb = l;
	
	else
		upb = r;
	
	y = leb + m / 2;
	x = upb + m / 2;
	
	while ( x + 2 * m <= n && examine(x + m * 2, y) )
		x += m * 2;
	
	while ( y + 2 * m <= n && examine(x, y + m * 2) )
		y += m * 2;
	
	cout << "solution " << x - 2 * m << " " << y - 2 * m;
}
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2 ms 248 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2 ms 248 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2 ms 248 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2 ms 248 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2 ms 376 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2 ms 376 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2 ms 248 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2 ms 248 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2 ms 376 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2 ms 252 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -