# | 제출 시각UTC-0 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
545198 | chonka | Construction of Highway (JOI18_construction) | C++98 | 862 ms | 28656 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std ;
#define MAXN 100007
#define LOG 20
int n ;
int a[ MAXN ] ;
pair < int , int > edges[ MAXN ] ;
vector < int > v[ MAXN ] ;
int pos_in_tree[ MAXN ] ;
int LCA[ MAXN ][ LOG ] ;
int subtree[ MAXN ] , heavy[ MAXN ] ;
int root[ MAXN ] ;
void dfs ( int vertex ) {
for ( int i = 1 ; i < LOG ; ++ i ) {
LCA[ vertex ][ i ] = LCA[ LCA[ vertex ][ i - 1 ] ][ i - 1 ] ;
}
subtree[ vertex ] = 1 ;
int mx = -1 ;
heavy[ vertex ] = 0 ;
for ( auto x : v[ vertex ] ) {
LCA[ x ][ 0 ] = vertex ;
dfs ( x ) ;
subtree[ vertex ] += subtree[ x ] ;
if ( mx < subtree[ x ] ) {
mx = subtree[ x ] ;
heavy[ vertex ] = x ;
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |