#include "Encoder.h"
#include <bits/stdc++.h>
using namespace std;
static vector < vector <int> > g;
static vector <int> idl, idr;
void dfs(int nod, int par, int &sz) {
idl[nod] = ++sz;
for(auto it : g[nod]) {
if(it != par) {
dfs(it, nod, sz);
}
}
idr[nod] = sz;
}
void Encode(int n, int A[], int B[]) {
g.resize(n);
int i;
for(i = 0; i < n - 1; i++) {
g[A[i]].push_back(B[i]);
g[B[i]].push_back(A[i]);
}
idl.resize(n), idr.resize(n);
int sz = 0;
dfs(0, -1, sz);
vector <int> aux = idr;
sort(aux.begin(), aux.end());
aux.resize(unique(aux.begin(), aux.end()) - aux.begin());
for(i = 0; i < n; i++) {
int a = idl[i], b = lower_bound(aux.begin(), aux.end(), idr[i]) - aux.begin();
Code(i, (b << 18) + a);
}
}
#include "Device.h"
#include <bits/stdc++.h>
using namespace std;
void InitDevice()
{
}
int Answer(long long S, long long T)
{
int ls = (S & ((1 << 18) - 1)), rs = ((S - ls) >> 18);
int lt = (T & ((1 << 18) - 1)), rt = ((T - lt) >> 18);
if(ls <= lt && rt <= rs) {
return 1;
}
if(lt <= ls && rs <= rt) {
return 0;
}
return 2;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
640 KB |
Output is correct |
2 |
Correct |
4 ms |
768 KB |
Output is correct |
3 |
Correct |
4 ms |
768 KB |
Output is correct |
4 |
Correct |
4 ms |
776 KB |
Output is correct |
5 |
Correct |
4 ms |
896 KB |
Output is correct |
6 |
Correct |
4 ms |
768 KB |
Output is correct |
7 |
Correct |
4 ms |
640 KB |
Output is correct |
8 |
Correct |
4 ms |
768 KB |
Output is correct |
9 |
Correct |
4 ms |
768 KB |
Output is correct |
10 |
Correct |
4 ms |
768 KB |
Output is correct |
11 |
Correct |
4 ms |
640 KB |
Output is correct |
12 |
Correct |
4 ms |
776 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
165 ms |
9112 KB |
Output is correct - L = 91488956 |
2 |
Correct |
165 ms |
9144 KB |
Output is correct - L = 88343227 |
3 |
Correct |
166 ms |
9236 KB |
Output is correct - L = 94896828 |
4 |
Correct |
166 ms |
9180 KB |
Output is correct - L = 91488956 |
5 |
Incorrect |
234 ms |
42264 KB |
Wrong Answer [3] |
6 |
Halted |
0 ms |
0 KB |
- |