Submission #431205

# Submission time Handle Problem Language Result Execution time Memory
431205 2021-06-17T10:17:03 Z amunduzbaev Aliens (IOI07_aliens) C++14
100 / 100
4 ms 256 KB
/* made by amunduzbaev */
#include "bits/stdc++.h"
using namespace std;
 
//~ #include <ext/pb_ds/assoc_container.hpp>
//~ #include <ext/pb_ds/tree_policy.hpp>
//~ using namespace __gnu_pbds;
//~ template<class T> using oset = tree<T, 
//~ null_type, less_equal<T>, rb_tree_tag, 
//~ tree_order_statistics_node_update>;
 
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define ub upper_bound
#define lb lower_bound
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(),x.rend()
#define NeedForSpeed ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define vv vector
#define mem(arr, v) memset(arr, v, sizeof arr)
#define int long long
#define degub(x) cout<<#x<<" : "<<x<<"\n"
#define GG cout<<"here"<<endl;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii; 
typedef vector<int> vii;
typedef vector<pii> vpii;
template<class T> bool umin(T& a, const T& b) { return a > b ? a = b, true : false; }
template<class T> bool umax(T& a, const T& b) { return a < b ? a = b, true : false; }
template<int sz> using tut = array<int, sz>;
void usaco(string s) { freopen((s+".in").c_str(),"r",stdin);  
	freopen((s+".out").c_str(),"w",stdout); NeedForSpeed }
 
const int N = 2e5+5;
const int mod = 1e9+7;
const ll inf = 1e18;
const ld Pi = acos(-1);
 
#define MULTI 0
int n, m, k, t, q, ans, res, a[N];

bool ask(int x, int y){
	if(x <= 0 || y <= 0 || x > n || y > n) return 0;
	cout<<"examine "<<x<<" "<<y<<endl;
	string s; cin>>s;
	return (s == "true");
}

void result(int x, int y){
	cout<<"solution "<<x<<" "<<y<<endl;
	return; 
}

void solve(int t_case){
	int x, y; cin>>n>>x>>y;
	int l = 1, r = y;
	for(int len=0;y > (1<<len); len++){
		if(ask(x, y - (1<<len))) continue;
		l = y - (1<<len); break;
	} while(l < r){
		int m = (l + r)>>1;
		if(ask(x, m)) r = m;
		else l = m + 1;
	} int lx, ly = l;
	
	l = 1, r = x;
	for(int len=0;x > (1<<len); len++){
		if(ask(x - (1<<len), y)) continue;
		l = x - (1<<len); break;
	} while(l < r){
		int m = (l + r)>>1;
		if(ask(m, y)) r = m;
		else l = m + 1;
	} lx = l;
	
	l = y, r = n;
	for(int len=0;y + (1<<len) <= n; len++){
		if(ask(x, y + (1<<len))) continue;
		r = y + (1<<len); break;
	} while(l < r){
		int m = (l + r + 1)>>1;
		if(ask(x, m)) l = m;
		else r = m - 1;
	} int rx, ry = l;
	
	l = x, r = n;
	for(int len=0;x + (1<<len) <= n; len++){
		if(ask(x + (1<<len), y)) continue;
		r = x + (1<<len); break;
	} while(l < r){
		int m = (l + r + 1)>>1;
		if(ask(m, y)) l = m;
		else r = m - 1;
	} rx = l;
	
	m = rx - lx + 1;
	for(int i=5;i>=1;i--){
		for(int j=5;j>=1;j--){
			int x = rx - m * i + 1, y = ry - m * j + 1;
			if(ask(x, y)){
				int xx = x + 5 * m - 1, yy = y + 5 * m - 1;
				//~ assert(ask(xx, yy));
				//~ x, xx
				//~ y, yy
				result((x + xx + 1)>>1, (y + yy + 1)>>1);
				return;
			}
		}
	}
}

signed main(){
	NeedForSpeed
	if(MULTI){
		int t; cin>>t;
		for(int t_case = 1; t_case <= t; t_case++) solve(t_case);
	} else solve(1);
	return 0;
}

Compilation message

aliens.cpp: In function 'void solve(long long int)':
aliens.cpp:69:12: warning: unused variable 'ly' [-Wunused-variable]
   69 |  } int lx, ly = l;
      |            ^~
aliens.cpp: In function 'void usaco(std::string)':
aliens.cpp:36:31: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   36 | void usaco(string s) { freopen((s+".in").c_str(),"r",stdin);
      |                        ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
aliens.cpp:37:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   37 |  freopen((s+".out").c_str(),"w",stdout); NeedForSpeed }
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 200 KB Output is correct
2 Correct 1 ms 200 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 200 KB Output is correct
2 Correct 2 ms 200 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 200 KB Output is correct
2 Correct 1 ms 200 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 200 KB Output is correct
2 Correct 1 ms 200 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 200 KB Output is correct
2 Correct 1 ms 200 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 200 KB Output is correct
2 Correct 3 ms 200 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 200 KB Output is correct
2 Correct 1 ms 200 KB Output is correct
3 Correct 2 ms 200 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 200 KB Output is correct
2 Correct 2 ms 200 KB Output is correct
3 Correct 3 ms 200 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 200 KB Output is correct
2 Correct 2 ms 200 KB Output is correct
3 Correct 1 ms 200 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 200 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 4 ms 200 KB Output is correct