#include "Encoder.h"
#include <bits/stdc++.h>
#define ll long long
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;
/*for(i = 0; i < n; i++) {
aux.push_back(idr[i] - idl[i]);
}*/
//sort(aux.begin(), aux.end());
//aux.resize(unique(aux.begin(), aux.end()) - aux.begin());
for(i = 0; i < n; i++) {
ll a = idl[i], b = idr[i] - idl[i];
Code(i, (b << 18) + a);
}
}
#include "Device.h"
#include <bits/stdc++.h>
#define ll long long
using namespace std;
void InitDevice()
{
}
int Answer(long long S, long long T)
{
ll ls = (S & ((1 << 18) - 1)), rs = ((S - ls) >> 18) + ls;
ll lt = (T & ((1 << 18) - 1)), rt = ((T - lt) >> 18) + lt;
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 |
776 KB |
Output is correct |
2 |
Correct |
4 ms |
896 KB |
Output is correct |
3 |
Correct |
4 ms |
640 KB |
Output is correct |
4 |
Correct |
5 ms |
804 KB |
Output is correct |
5 |
Correct |
4 ms |
904 KB |
Output is correct |
6 |
Correct |
4 ms |
768 KB |
Output is correct |
7 |
Correct |
4 ms |
640 KB |
Output is correct |
8 |
Correct |
5 ms |
904 KB |
Output is correct |
9 |
Correct |
4 ms |
984 KB |
Output is correct |
10 |
Correct |
4 ms |
776 KB |
Output is correct |
11 |
Correct |
4 ms |
864 KB |
Output is correct |
12 |
Correct |
3 ms |
864 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
185 ms |
9776 KB |
Output is correct - L = 183238657 |
2 |
Correct |
163 ms |
9784 KB |
Output is correct - L = 182976513 |
3 |
Correct |
162 ms |
9688 KB |
Output is correct - L = 183238657 |
4 |
Correct |
160 ms |
9680 KB |
Output is correct - L = 183238657 |
5 |
Partially correct |
499 ms |
56424 KB |
Output is partially correct - L = 65535737857 |
6 |
Partially correct |
494 ms |
55792 KB |
Output is partially correct - L = 65535737857 |
7 |
Partially correct |
520 ms |
55792 KB |
Output is partially correct - L = 65535737857 |
8 |
Partially correct |
498 ms |
55376 KB |
Output is partially correct - L = 65535737857 |
9 |
Partially correct |
422 ms |
57056 KB |
Output is partially correct - L = 65535737857 |
10 |
Partially correct |
398 ms |
57144 KB |
Output is partially correct - L = 65535737857 |
11 |
Partially correct |
412 ms |
57376 KB |
Output is partially correct - L = 65535737857 |
12 |
Partially correct |
413 ms |
57088 KB |
Output is partially correct - L = 65535737857 |
13 |
Partially correct |
446 ms |
56544 KB |
Output is partially correct - L = 65535737857 |
14 |
Partially correct |
491 ms |
56296 KB |
Output is partially correct - L = 65535737857 |
15 |
Correct |
159 ms |
9540 KB |
Output is correct - L = 183238657 |
16 |
Correct |
160 ms |
9872 KB |
Output is correct - L = 183238657 |
17 |
Correct |
160 ms |
9792 KB |
Output is correct - L = 183238657 |
18 |
Partially correct |
465 ms |
56168 KB |
Output is partially correct - L = 65535737857 |
19 |
Partially correct |
452 ms |
56176 KB |
Output is partially correct - L = 65535737857 |
20 |
Partially correct |
498 ms |
56192 KB |
Output is partially correct - L = 65535737857 |
21 |
Partially correct |
472 ms |
56168 KB |
Output is partially correct - L = 65535737857 |
22 |
Partially correct |
498 ms |
56288 KB |
Output is partially correct - L = 65535737857 |
23 |
Partially correct |
481 ms |
55976 KB |
Output is partially correct - L = 65535737857 |
24 |
Partially correct |
458 ms |
55920 KB |
Output is partially correct - L = 65535737857 |
25 |
Partially correct |
485 ms |
55792 KB |
Output is partially correct - L = 65535737857 |
26 |
Partially correct |
499 ms |
56048 KB |
Output is partially correct - L = 65535737857 |
27 |
Partially correct |
523 ms |
55536 KB |
Output is partially correct - L = 65535737857 |