| # | Time | Username | Problem | Language | Result | Execution time | Memory | 
|---|---|---|---|---|---|---|---|
| 363445 | idontreallyknow | Poklon (COCI17_poklon7) | C++14 | 454 ms | 111192 KiB | 
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
template <class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
mt19937/*_64*/ rng(chrono::steady_clock::now().time_since_epoch().count());
#define printArr(arr, n) cerr << #arr << " = ["; for(int i=0; i<(n); i++){if (i) cerr << ", "; cerr << arr[i];} cerr << "]\n"
template<class A> ostream& operator<<(ostream &cout, vector<A> const &v) {cout << "["; for(int i = 0; i < v.size(); i++) {if (i) cout << ", "; cout << v[i];} return cout << "]";};
template<class A, class B> ostream& operator<<(ostream &cout, const pair<A,B> &x) {return cout << "(" <<x.first << ", " << x.second << ")";};
void _print() {cerr << "]\n";}
template <class T, class... V> void _print(T t, V... v) {cerr << t; if (sizeof...(v)) cerr << ", "; _print(v...);}
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#define fi first
#define se second
#define SZ(x) (int)((x).size())
#define pii pair<int,int>
const int mx = 1e6+50;
ll a[mx], b[mx], depth[mx];
vector<pii> stuff;
void dfs(int v)
{
	if (a[v] <= 0) {
		stuff.emplace_back(-a[v],depth[v]+1);
	} else {
		depth[a[v]] = depth[v]+1;
		dfs(a[v]);
	}
	if (b[v] <= 0) {
		stuff.emplace_back(-b[v],depth[v]+1);
	} else {
		depth[b[v]] = depth[v]+1;
		dfs(b[v]);
	}
}
const ll inf = (1LL<<33);
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
	for (int q = 1; q <= n; q++) cin >> a[q] >> b[q];
	dfs(1);
	vector<pair<ll,ll>> things;
	for (pii e : stuff) {
		if (e.fi == 0) {
			things.emplace_back(-1,0);
			continue;
		}
		int msb = 31 - __builtin_clz(e.fi);
		ll x = e.fi;
		if (msb+e.se >= 33) {
			while (x < inf) x *= 2;
		} else {
			int msb1 = e.se;
			while (msb1 > 0) {
				msb1--;
				x *= 2;
			}
		}
		things.emplace_back(msb+e.se,x);
	}
	sort(things.begin(), things.end());
	ll x,y;
	tie(x,y) = things.back();
	if (x == -1) {
		cout << "0\n";
		return 0;
	}
	if (x < 33) {
		for (int q = x; q >= 0; q--) {
			cout << (((1LL<<q)&y) > 0 ? 1 : 0);
		}
		cout << "\n";
	} else {
		for (int q = 33; q >= 0; q--) {
			cout << ((((1LL<<q)&y) > 0) ? 1 : 0);
			x--;
		}
		while (x >= 0) {
			cout << 0;
			x--;
		}
		cout << "\n";
	}
	return 0;
}
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
