Submission #467013

# Submission time Handle Problem Language Result Execution time Memory
467013 2021-08-21T09:48:49 Z nikolapesic2802 popa (BOI18_popa) C++14
100 / 100
130 ms 452 KB
#include <bits/stdc++.h>
#include "popa.h"

using namespace std;

#define ll long long
#define pb push_back

int nxt;
vector<int> parent;
void take(int poz,int n,int* Left,int* Right)
{
    nxt++;
    while(nxt<n&&query(poz,poz,poz,nxt))
    {
        Left[nxt]=Right[poz];
        Right[poz]=nxt;
        parent[nxt]=poz;
        take(nxt,n,Left,Right);
    }
}
int solve(int n,int* Left,int* Right)
{
    for(int i=0;i<n;i++)
    {
        Left[i]=-1;
        Right[i]=-1;
    }
    parent.resize(n);
    fill(parent.begin(),parent.end(),-1);
    int root=-1;
    nxt=0;
    for(int i=0;i<n;i++)
    {
        if(parent[i]==-1){
            if(root!=-1){
                Left[i]=root;
                parent[root]=i;
            }
            root=i;
            take(i,n,Left,Right);
        }
    }
    return root;
}
# Verdict Execution time Memory Grader output
1 Correct 8 ms 200 KB Output is correct
2 Correct 11 ms 200 KB Output is correct
3 Correct 13 ms 200 KB Output is correct
4 Correct 12 ms 200 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 113 ms 328 KB Output is correct
2 Correct 113 ms 328 KB Output is correct
3 Correct 90 ms 200 KB Output is correct
4 Correct 118 ms 284 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 120 ms 324 KB Output is correct
2 Correct 130 ms 432 KB Output is correct
3 Correct 126 ms 420 KB Output is correct
4 Correct 107 ms 452 KB Output is correct