답안 #437076

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
437076 2021-06-25T18:36:33 Z 2548631 Poklon (COCI17_poklon7) C++17
48 / 120
344 ms 64768 KB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef complex<ld> cp;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vii;
typedef vector<cp> vcp;
typedef vector<ld> vld;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<vii> vvii;

#define fastIO ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
#define forw(i,l,r) for( int i = (l) ; i < (r) ; i++ )
#define forb(i,r,l) for( int i = (r) ; i >= (l) ; i-- )
#define log2i(x) (64 - __builtin_clzll(1ll*(x)) - 1)
#define numBit(x) (__builtin_popcountll(1ll*(x)))
#define getBit(x,i) (x>>i&1)
#define Pi acos(-1.0l)
#define sz(x) (int)x.size()
#define mt make_tuple
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define debug(x) cerr << #x << " = " << x << '\n';

const int N = 1e6+7;
int n;
int l[N],r[N];
ll dp[N];

ll dfs(int x) {
    if(x<0) return -x;
    dp[x]=2*max(dfs(l[x]),dfs(r[x]));
    return dp[x];
}

void print(ll x) {
    if(x==0) return;
    print(x/2);
    cout << x%2;
}

int main() {
    fastIO;
#ifndef ONLINE_JUDGE
    //freopen("test.inp","r",stdin);
    //freopen("test.out","w",stdout);
#endif // ONLINE_JUDGE

    cin >> n;
    forw(i,1,n+1) cin >> l[i] >> r[i];
    ll ans=dfs(1);
    print(ans);
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 320 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 324 KB Output is correct
9 Incorrect 1 ms 332 KB Output isn't correct
10 Incorrect 1 ms 328 KB Output isn't correct
11 Incorrect 5 ms 716 KB Output isn't correct
12 Incorrect 5 ms 716 KB Output isn't correct
13 Incorrect 15 ms 2636 KB Output isn't correct
14 Incorrect 28 ms 5116 KB Output isn't correct
15 Incorrect 27 ms 3512 KB Output isn't correct
16 Incorrect 92 ms 15212 KB Output isn't correct
17 Incorrect 240 ms 34528 KB Output isn't correct
18 Incorrect 241 ms 36036 KB Output isn't correct
19 Incorrect 333 ms 38820 KB Output isn't correct
20 Incorrect 344 ms 64768 KB Output isn't correct