/// Author: Wang, Yen-Jen
#include "Encoder.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
static const int MAX_N = 250000 + 7;
static int dfs_clock;
static vector<int> G[MAX_N];
static int lb[MAX_N] , rb[MAX_N];
static int dfs(int u , int fa) {
lb[u] = rb[u] = ++dfs_clock;
for(int v : G[u]) {
if(v != fa) rb[u] = max(rb[u] , dfs(v , u));
}
return rb[u];
}
void Encode(int N , int A[] , int B[]) {
for(int i = 0; i < N; i++) G[i].clear();
for(int i = 0; i < N - 1; i++) {
G[A[i]].push_back(B[i]);
G[B[i]].push_back(A[i]);
}
dfs_clock = 0;
dfs(0 , -1);
for(int i = 0; i < N; i++) Code(i , lb[i]<<19|rb[i]);
}
/// Author: Wang, Yen-Jen
#include "Device.h"
#include <bits/stdc++.h>
using namespace std;
void InitDevice() {
}
int Answer(long long S , long long T) {
int sl = S>>19;
int sr = S&((1<<19)-1);
int tl = T>>19;
int tr = T&((1<<19)-1);
if(tl <= sl && sr <= tr) return 0;
else if(sl <= tl && tr <= sr) return 1;
else return 2;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
12288 KB |
Output is correct |
2 |
Correct |
8 ms |
12288 KB |
Output is correct |
3 |
Correct |
8 ms |
12456 KB |
Output is correct |
4 |
Correct |
8 ms |
12544 KB |
Output is correct |
5 |
Correct |
9 ms |
12288 KB |
Output is correct |
6 |
Correct |
8 ms |
12544 KB |
Output is correct |
7 |
Correct |
9 ms |
12544 KB |
Output is correct |
8 |
Correct |
9 ms |
12288 KB |
Output is correct |
9 |
Correct |
9 ms |
12288 KB |
Output is correct |
10 |
Correct |
8 ms |
12544 KB |
Output is correct |
11 |
Correct |
9 ms |
12544 KB |
Output is correct |
12 |
Correct |
9 ms |
12544 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
165 ms |
19552 KB |
Output is partially correct - L = 367002300 |
2 |
Partially correct |
167 ms |
19392 KB |
Output is partially correct - L = 366478011 |
3 |
Partially correct |
168 ms |
21768 KB |
Output is partially correct - L = 367002300 |
4 |
Partially correct |
170 ms |
21744 KB |
Output is partially correct - L = 367002300 |
5 |
Incorrect |
200 ms |
42176 KB |
Wrong Answer [3] |
6 |
Halted |
0 ms |
0 KB |
- |