Submission #105510

# Submission time Handle Problem Language Result Execution time Memory
105510 2019-04-13T04:06:22 Z SOIVIEONE Aliens (IOI07_aliens) C++14
30 / 100
4 ms 412 KB
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
 
#define INF 1000000021
#define MOD 1000000007
#define pb push_back
#define sqr(a) (a)*(a)
#define M(a, b) make_pair(a,b)
#define T(a, b, c) make_pair(a, make_pair(b, c))
#define F first
#define S second
#define all(x) (x.begin(), x.end())
#define deb(x) cerr << #x << " = " << x << '\n'
#define N 222222
 
using namespace std;
//using namespace __gnu_pbds;
 
typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
 
const ld pi = 2 * acos(0.0);
template<class T> bool umin(T& a, T b){if(a>b){a=b;return 1;}return 0;}
template<class T> bool umax(T& a, T b){if(a<b){a=b;return 1;}return 0;}
template<class T, class TT> bool pal(T a, TT n){int k=0;for(int i=0;i<=n/2;i++){if(a[i]!=a[n-i-1]){k=1;break;}}return k?0:1;}
 
//int month[] = {0,31,28,31,30,31,30,31,31,30,31,30,31};
ll n;
int kar = 0;
map<pii, int > mp;
int ask(ll x, ll y)
{
	if(!(x >= 0 && x <= n) || !(y >= 0 && y <= n))
		return 0;
	if(mp.count(M(x, y)))
		return mp[M(x, y)];
	kar ++;
	cout << "examine " << x << ' ' << y << '\n';
	cout.flush();
	string q;
	cin >> q;
	return mp[M(x, y)] = (q[0] == 't');
}
 
int main()
{
	ll x, y;
	cin >> n >> x >> y;
	ll p = 1;
	while(x + p <= n && ask(x + p, y))
		p *= 2;
//	cout << "first\n";
	ll l = x + p / 2, r = min(x + p, n);
	ll hoo = 0;
	ll pl = -1, pr = -1;
	ll trash = 60;
	while(trash --)
	{
		ll m = (l + r) >> 1ll;
		if(ask(m, y))
		{
			hoo = m;
			l = m;
		}
		else
			r = m - 1;
	}
	if(ask(l, y))
		if(l > hoo)
			hoo = l;
		if(ask(r, y))
			if(r > hoo)
				hoo = r;
//	cout << "second\n";	
	p = 1;
	while(x - p >= 0 && ask(x - p, y))
		p *= 2;
//	cout << "fourth\n";		
	l = max(x - p, 0ll); r = x - p / 2;
	ll foo = l;
	while(l < r)
	{
		ll m = (l + r) >> 1ll;
		if(ask(m, y)) 
		{
			foo = m;
			r = m;
		}
		else
			l = m + 1;
	}
	if(ask(l, y))
		if(l > foo)
			foo = l;
//	cout << "fifth\n";
	ll M = hoo - foo + 1;
	ll cur = foo, lx = 1,lef = foo;
	while(cur - M - M >= 0 && ask(cur-M-M, y))
	{
		cur -= (M + M);
		lef = cur;
		lx ++;
	}
	p = 1;
	while(y+p <= n && ask(x, y + p))
		p *= 2;
	l = y + p / 2; r = min(y + p, n);
//	cout << "sixth\n"; 
	ll ry = l;
	pl = pr = -1;
	trash = 60;
	while(trash --)
	{
		ll m = (l + r) >> 1ll;
		if(ask(x, m))
			l = m,
			ry = m;
		else
			r = m-1;
		pl = l;
		pr = r;
	}
	if(ask(x, l))
		if(l > ry)
		ry = l;
	if(ask(x, r))
		if(r > ry)
			ry = r;
	cur = ry;
	ll oo = 0, up = cur;
	while(ask(x, cur+M+M) && cur + M + M <= n)
	{
		cur += M+M;
		up = cur;
	}
	ll rx = lef;
	ry = up;
	ll ax = M*5+rx-1, ay = -M*5+ry+1;
	cout << "solution " << (rx + ax) / 2 << ' ' << (ry + ay) / 2 << '\n';
	cout.flush();
 
	getchar();
	getchar();
	return 0;
	//ios::sync_with_stdio(false);
	//cin.tie(0);
}

Compilation message

aliens.cpp: In function 'int main()':
aliens.cpp:73:2: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
  if(ask(l, y))
  ^~
aliens.cpp:76:3: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   if(ask(r, y))
   ^~
aliens.cpp:60:5: warning: variable 'pl' set but not used [-Wunused-but-set-variable]
  ll pl = -1, pr = -1;
     ^~
aliens.cpp:135:5: warning: unused variable 'oo' [-Wunused-variable]
  ll oo = 0, up = cur;
     ^~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Incorrect 2 ms 384 KB Incorrect
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 3 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 3 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Incorrect 1 ms 284 KB Incorrect
# Verdict Execution time Memory Grader output
1 Correct 3 ms 384 KB Output is correct
2 Incorrect 2 ms 256 KB Incorrect
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 384 KB Incorrect
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Incorrect 3 ms 384 KB Incorrect
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Incorrect 2 ms 256 KB Incorrect
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 3 ms 412 KB Output is correct
3 Correct 3 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 256 KB Output is correct
2 Correct 4 ms 356 KB Output is correct
3 Incorrect 3 ms 384 KB Incorrect