Submission #315400

# Submission time Handle Problem Language Result Execution time Memory
315400 2020-10-22T20:41:05 Z Ahmad_Hasan Poklon (COCI17_poklon7) C++17
42 / 120
1000 ms 16632 KB
#include <bits/stdc++.h>

using namespace std;

vector<pair<long long,long long> >vps;
int cntdpth=1;

long long trg;
long long slvmx(int cr=0,int dpth=1){
    cntdpth=max(cntdpth,dpth);
    long long mx=-1ll;
    if(vps[cr].first<0){
        mx=max(mx,vps[cr].first*-1ll);
    }else{
        mx=max(mx,slvmx(vps[cr].first-1,dpth+1)*2ll);
    }
    if(vps[cr].second<0){
        mx=max(mx,vps[cr].second*-1ll);
    }else{
        mx=max(mx,slvmx(vps[cr].second-1,dpth+1)*2ll);
    }
    return mx;
}

int main()
{
    int n;
    cin>>n;
    vps=vector<pair<long long,long long> >(n);
    for(int i=0;i<n;i++){
        long long x,y;
        cin>>x>>y;
        vps[i]={x,y};
    }
    trg=2ll*slvmx();
    trg+=(trg%(1ll<<cntdpth)==0ll)?0ll:((1ll<<cntdpth)-(trg%cntdpth));

    string binary = std::bitset<64>(trg).to_string();
    binary.erase(0, binary.find_first_not_of('0'));
    cout << binary;

    return 0;
}

/***
3 5 4
1 2 4 2 1
3 5 1 2 4
1 5 7 1 2

*/
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 0 ms 256 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Incorrect 0 ms 256 KB Output isn't correct
6 Correct 0 ms 256 KB Output is correct
7 Correct 1 ms 256 KB Output is correct
8 Correct 1 ms 256 KB Output is correct
9 Incorrect 1 ms 384 KB Output isn't correct
10 Incorrect 2 ms 384 KB Output isn't correct
11 Incorrect 14 ms 640 KB Output isn't correct
12 Incorrect 18 ms 640 KB Output isn't correct
13 Incorrect 75 ms 1912 KB Output isn't correct
14 Incorrect 148 ms 3448 KB Output isn't correct
15 Incorrect 146 ms 1940 KB Output isn't correct
16 Incorrect 519 ms 9492 KB Output isn't correct
17 Execution timed out 1055 ms 12672 KB Time limit exceeded
18 Execution timed out 1056 ms 12800 KB Time limit exceeded
19 Execution timed out 1090 ms 16000 KB Time limit exceeded
20 Execution timed out 1096 ms 16632 KB Time limit exceeded