이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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 |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |