Submission #258073

#TimeUsernameProblemLanguageResultExecution timeMemory
258073mieszko11bColors (BOI20_colors)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

using ll = long long;
using ld = long double;
using ii = pair<int, int>;
using pll = pair<ll, ll>;
using uid = uniform_int_distribution<int>;

using ordered_set = tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>;
using ordered_multiset = tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update>;

const int inf = int(1e9) + 7;
const ll INF = ll(1e18) + 7;

#define X first
#define Y second

//~ mt19937 rng(chrono::steady_clock().now().time_since_epoch().count());

//~ int rand(int a, int b) {
	//~ return uid(a, b)(rng);
//~ }

void boost() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
}

ll n;
ll act;
vector<ll> hist;

bool ask(ll x) {
	if(x > n) {
		int a = hist[hist.size() - 3];
		int b = hist[hist.size() - 2];
		int c = hist[hist.size() - 1];
		
		ask(a - (b - c));
		x -= c - hist.back();
	}
	if(x < 1) {
		int a = hist[hist.size() - 3];
		int b = hist[hist.size() - 2];
		int c = hist[hist.size() - 1];		
		
		ask(a + (c - b));
		x += hist.back() - c;
	}
	
	act = x;
	hist.push_back(x);
	cout << "? " << x << endl;
	//~ fflush(stdout);
	int xx;
	cin >> xx;
	//~ cout << xx << endl;
	return (xx == 1);
}

void solve() {
	cin >> n;
	ll first = 1;
	ll m = 0, pocz = 1, mid;
	while(pocz < n) {
		mid = (pocz + n) / 2;
		if(m)
			first += (mid - pocz + 1);
		m ^= 1;
		pocz = mid + 1;
	}
	
	ask(first);
	int dir = 1;
	pocz = 1;
	ll kon = n;
	while(pocz < kon) {
		mid = (pocz + kon) / 2;
		if(ask(act + ll(dir) * mid))
			kon = mid;
		else
			pocz = mid + 1;
		dir = -dir;
	}
	
	cout << "= " << pocz << endl;
	//~ fflush(stdout);
}

int main() {
	//~ boost();
	//~ int t = 1;
	cin >> t;
	while(t--) {
		solve();
	}
	return 0;
}

Compilation message (stderr)

Colors.cpp: In function 'int main()':
Colors.cpp:98:9: error: 't' was not declared in this scope
  cin >> t;
         ^