Submission #123444

# Submission time Handle Problem Language Result Execution time Memory
123444 2019-07-01T12:48:39 Z TuGSGeReL Aliens (IOI07_aliens) C++17
100 / 100
4 ms 380 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<ll, null_type, less_equal<ll>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
using pll = pair <int, int>;
using pii = pair <ll, ll>;

ll n, x, y, k = 1, rib, leb, upb, m;
	
bool examine(ll a, ll b)
{
	if ( a <= 0 || b <= 0 || a > n || b > n )
		return 0;
	
	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;

	while (examine(x, k + y))
		k = k * 2;
	
	ll l = y, r = y + k;
	
	while (l + 1 < r)
	{
		ll mid = (l + r) / 2;
		
		if ( examine(x, mid) )
			l = mid;
		
		else
			r = mid;
	}
	
	if ( examine(x, r) )
		rib = r;
	
	else
		rib = l;
	
	k = 1;
	while (examine(x, y - k))
		k = k * 2;
	
	l = y - k, r = y;

	while (l + 1 < r)
	{
		ll 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;
	
	k = 1;
	while (examine(x - k, y))
		k = k * 2;
	
	l = x - k, r = x;
	
	while (l + 1 < r)
	{
		ll 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;
	
	if ( examine(x + m, y + m) )
		x += m, y += m;
	
	cout << "solution " << x - 2 * m << " " << y - 2 * m << "\n";
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 380 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 3 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 3 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 248 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 380 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 4 ms 252 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 3 ms 248 KB Output is correct
3 Correct 3 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 3 ms 248 KB Output is correct
3 Correct 3 ms 248 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 248 KB Output is correct
2 Correct 4 ms 376 KB Output is correct
3 Correct 2 ms 248 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 248 KB Output is correct
2 Correct 3 ms 376 KB Output is correct
3 Correct 4 ms 248 KB Output is correct