Submission #168167

#TimeUsernameProblemLanguageResultExecution timeMemory
168167sansPoklon (COCI17_poklon7)C++14
18 / 120
621 ms262144 KiB
#include <iostream> #include <numeric> #include <cmath> #include <algorithm> #include <vector> #include <stack> using namespace std; #define sp ' ' #define st first #define nd second #define pb push_back #define mp make_pair #define forn(YY, yy) for(long long int yy = 0; yy < YY; ++yy) #define prn(XX) cout << XX << endl #define prs(XX) cout << XX << " " typedef long long int ll; typedef unsigned long long int ull; typedef vector<ll> vll; typedef vector<vector<ll>> vvll; typedef pair<ll, ll> pll; typedef vector<pll> vpll; const int MOD = 1e9 + 7; const int INF = 2e9 + 13; const int mINF = -2e9 - 13; const double PI = 3.14159265358979; const double EPS = 1e-9; struct Scale{ ll left; ll right; }; vector<Scale> sc; vector<ll> tree; vector<vector<ll>> AdjList; ll maxy = 0; ll build(ll n, ll node, ll depth){ if(sc[n].left > 0) tree[2*node+1] = build(sc[n].left, 2*node+1, depth+1); else{ tree[2*node+1] = -sc[n].left; maxy = max(maxy, (1 << depth)*tree[2*node+1]); } if(sc[n].right > 0) tree[2*node+2] = build(sc[n].right, 2*node+2, depth+1); else{ tree[2*node+2] = -sc[n].right; maxy = max(maxy, (1 << depth)*tree[2*node+2]); } return tree[node] = tree[2*node+1] + tree[2*node+2]; } int main(int argc, char **argv){ ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); ll N; cin >> N; sc.resize(N); tree.resize(6*N, -1); for(int i = 0; i < N; ++i){ cin >> sc[i].left >> sc[i].right; if(sc[i].left > 0) --sc[i].left; if(sc[i].right > 0) --sc[i].right; } build(0, 0, 1); stack<int> bin; while(maxy){ bin.push(maxy%2); maxy >>= 1; } while(!bin.empty()){ int top = bin.top(); cout << top; bin.pop(); } cout << endl; return 0; } //cikisir
#Verdict Execution timeMemoryGrader output
Fetching results...