답안 #92380

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
92380 2019-01-02T17:16:10 Z igzi popa (BOI18_popa) C++17
100 / 100
89 ms 376 KB
#include <bits/stdc++.h>
#include "popa.h"
#define maxN 1005

using namespace std;

int solve(int n, int* l, int* d){
for(int i=0;i<n;i++) l[i]=d[i]=-1;
int root,i,j,tmp,pom;
vector <int> v;
root=0;
for(i=1;i<n;i++){
tmp=root;
while(tmp!=-1){
v.push_back(tmp);
tmp=d[tmp];
}
pom=-1;
for(j=v.size()-1;j>=0;j--){
    if(!query(v[j],i,i,i)) break;
    pom=j;
}
if(pom==-1) {l[i]=-1; d[v.back()]=i;}
if(pom==0) {l[i]=v[0]; root=i;}
if(pom>0) {
l[i]=v[pom];
d[v[pom-1]]=i;
}
v.clear();
}
return root;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 248 KB Output is correct
2 Correct 5 ms 248 KB Output is correct
3 Correct 8 ms 248 KB Output is correct
4 Correct 8 ms 248 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 84 ms 376 KB Output is correct
2 Correct 76 ms 376 KB Output is correct
3 Correct 61 ms 376 KB Output is correct
4 Correct 89 ms 248 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 80 ms 376 KB Output is correct
2 Correct 75 ms 320 KB Output is correct
3 Correct 62 ms 328 KB Output is correct
4 Correct 58 ms 328 KB Output is correct