# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
26898 | wangyenjen | City (JOI17_city) | C++14 | 542 ms | 56576 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
/// 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 , (ll)lb[i]<<18|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>>18;
int sr = S&((1<<18)-1);
int tl = T>>18;
int tr = T&((1<<18)-1);
if(tl <= sl && sr <= tr) return 0;
else if(sl <= tl && tr <= sr) return 1;
else return 2;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |