#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 = idr;
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 = lower_bound(aux.begin(), aux.end(), idr[i]) - aux.begin();
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);
ll 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 |
896 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 |
896 KB |
Output is correct |
5 |
Correct |
4 ms |
768 KB |
Output is correct |
6 |
Correct |
4 ms |
864 KB |
Output is correct |
7 |
Correct |
3 ms |
776 KB |
Output is correct |
8 |
Correct |
4 ms |
768 KB |
Output is correct |
9 |
Correct |
3 ms |
776 KB |
Output is correct |
10 |
Correct |
4 ms |
904 KB |
Output is correct |
11 |
Correct |
4 ms |
640 KB |
Output is correct |
12 |
Correct |
4 ms |
640 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
164 ms |
9172 KB |
Output is correct - L = 91488956 |
2 |
Correct |
162 ms |
9112 KB |
Output is correct - L = 88343227 |
3 |
Correct |
163 ms |
9224 KB |
Output is correct - L = 94896828 |
4 |
Correct |
161 ms |
9136 KB |
Output is correct - L = 91488956 |
5 |
Partially correct |
561 ms |
55536 KB |
Output is partially correct - L = 32979013776 |
6 |
Partially correct |
526 ms |
55296 KB |
Output is partially correct - L = 33131057296 |
7 |
Partially correct |
532 ms |
55144 KB |
Output is partially correct - L = 33010208912 |
8 |
Partially correct |
527 ms |
54648 KB |
Output is partially correct - L = 32767987856 |
9 |
Partially correct |
464 ms |
56544 KB |
Output is partially correct - L = 62321315984 |
10 |
Partially correct |
454 ms |
56608 KB |
Output is partially correct - L = 65233735824 |
11 |
Partially correct |
461 ms |
56616 KB |
Output is partially correct - L = 65500336272 |
12 |
Partially correct |
487 ms |
56784 KB |
Output is partially correct - L = 65528909968 |
13 |
Partially correct |
537 ms |
56112 KB |
Output is partially correct - L = 50202923152 |
14 |
Partially correct |
559 ms |
56088 KB |
Output is partially correct - L = 40527974544 |
15 |
Correct |
168 ms |
9240 KB |
Output is correct - L = 93323964 |
16 |
Correct |
163 ms |
9120 KB |
Output is correct - L = 90702524 |
17 |
Correct |
164 ms |
9372 KB |
Output is correct - L = 89391804 |
18 |
Partially correct |
495 ms |
55600 KB |
Output is partially correct - L = 34468778128 |
19 |
Partially correct |
501 ms |
55744 KB |
Output is partially correct - L = 32930517136 |
20 |
Partially correct |
510 ms |
55792 KB |
Output is partially correct - L = 32781095056 |
21 |
Partially correct |
510 ms |
55864 KB |
Output is partially correct - L = 42191802512 |
22 |
Partially correct |
519 ms |
55608 KB |
Output is partially correct - L = 26558582928 |
23 |
Partially correct |
525 ms |
55552 KB |
Output is partially correct - L = 26532892816 |
24 |
Partially correct |
550 ms |
55440 KB |
Output is partially correct - L = 22031356048 |
25 |
Partially correct |
550 ms |
55712 KB |
Output is partially correct - L = 18864394384 |
26 |
Partially correct |
550 ms |
55376 KB |
Output is partially correct - L = 16501428368 |
27 |
Partially correct |
571 ms |
55240 KB |
Output is partially correct - L = 13163286672 |