#include<bits/stdc++.h>
#include "Encoder.h"
using namespace std;
const int N=250009;
int a,b,c,d,e,i,j,lf[250009],rg[250009],f[250009],tim;
vector <int> v[250009];
void dfs(int q, int w){
tim++;
lf[q]=rg[q]=tim;
for(vector <int>::iterator it=v[q].begin(); it!=v[q].end(); it++){
if((*it)==w) continue;
dfs((*it),q);
if(rg[q]<rg[(*it)]) rg[q]=rg[(*it)];
}
}
void Encode(int n, int A[], int B[]){
a=n;
for(i=0; i<a-1; i++){
v[A[i]+1].push_back(B[i]+1);
v[B[i]+1].push_back(A[i]+1);
}
dfs(1,0);
for(i=1; i<=a; i++) Code(i-1,lf[i]*N+rg[i]);
}
#include<bits/stdc++.h>
#include "Device.h"
using namespace std;
const int n=250009;
int l[4],r[4];
void InitDevice() {
}
bool anc(int q, int w){
if(l[q]<=l[w]&&r[q]>=r[w]) return 1; else return 0;
}
int Answer(long long S, long long T) {
l[1]=S/n;r[1]=S%n;
l[2]=T/n;r[2]=T%n;
if(anc(1,2)) return 0;
if(anc(2,1)) return 1;
return 2;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
5 ms |
12544 KB |
Wrong Answer [6] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
219 ms |
26608 KB |
Wrong Answer [6] |
2 |
Halted |
0 ms |
0 KB |
- |