#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#include "Encoder.h"
const int maxn = 5e5 + 10;
const double w = 1.05;
vector<int> e[maxn];
int t;
void dfs(int v, int par){
int tin = t++;
for (int i : e[v])
if (i != par)
dfs(i, v);
int val = 0;
double kek = 1;
while ((int)kek < t - tin)
val++, kek *= w;
t = tin + (int)kek;
Code(v, val * (ll)maxn + tin);
}
void Encode(int N, int A[], int B[])
{
int n = N;
for (int i = 0; i < n - 1; i++){
int v = A[i], u = B[i];
e[v].push_back(u);
e[u].push_back(v);
}
dfs(0, -1);
}
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#include "Encoder.h"
const int maxn = 5e5 + 10;
const double w = 1.05;
double mas[2000];
void InitDevice(){
mas[0] = 1;
for (int i = 1; i < 2000; i++)
mas[i] = mas[i - 1] * w;
}
int Answer(long long S, long long T)
{
int a = S / maxn, b = S % maxn, c = T / maxn, d = T % maxn;
a = b + (int)mas[a] - 1;
c = d + (int)mas[c] - 1;
if (a >= c && b <= d)
return 1;
if (a <= c && b >= d)
return 0;
return 2;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
14 ms |
24064 KB |
Output is correct |
2 |
Correct |
13 ms |
24072 KB |
Output is correct |
3 |
Correct |
13 ms |
24064 KB |
Output is correct |
4 |
Correct |
13 ms |
24064 KB |
Output is correct |
5 |
Correct |
13 ms |
24064 KB |
Output is correct |
6 |
Correct |
13 ms |
24064 KB |
Output is correct |
7 |
Correct |
11 ms |
24064 KB |
Output is correct |
8 |
Correct |
12 ms |
24064 KB |
Output is correct |
9 |
Correct |
12 ms |
24064 KB |
Output is correct |
10 |
Correct |
13 ms |
24064 KB |
Output is correct |
11 |
Correct |
14 ms |
24064 KB |
Output is correct |
12 |
Correct |
14 ms |
24320 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
213 ms |
31128 KB |
Output is correct - L = 68001360 |
2 |
Correct |
178 ms |
31152 KB |
Output is correct - L = 68501370 |
3 |
Correct |
180 ms |
31216 KB |
Output is correct - L = 68001360 |
4 |
Correct |
177 ms |
31264 KB |
Output is correct - L = 68501370 |
5 |
Correct |
500 ms |
63424 KB |
Output is correct - L = 129502590 |
6 |
Correct |
505 ms |
62976 KB |
Output is correct - L = 130002600 |
7 |
Correct |
512 ms |
63056 KB |
Output is correct - L = 130002600 |
8 |
Correct |
501 ms |
62416 KB |
Output is correct - L = 131502630 |
9 |
Correct |
428 ms |
64376 KB |
Output is correct - L = 135002700 |
10 |
Correct |
429 ms |
64448 KB |
Output is correct - L = 136002720 |
11 |
Correct |
416 ms |
64544 KB |
Output is correct - L = 136002720 |
12 |
Correct |
423 ms |
64408 KB |
Output is correct - L = 136002720 |
13 |
Correct |
459 ms |
64080 KB |
Output is correct - L = 132502650 |
14 |
Correct |
506 ms |
63408 KB |
Output is correct - L = 130502610 |
15 |
Correct |
176 ms |
31216 KB |
Output is correct - L = 68001360 |
16 |
Correct |
178 ms |
31248 KB |
Output is correct - L = 68001360 |
17 |
Correct |
178 ms |
31072 KB |
Output is correct - L = 68001360 |
18 |
Correct |
472 ms |
63736 KB |
Output is correct - L = 135502710 |
19 |
Correct |
460 ms |
63456 KB |
Output is correct - L = 135502710 |
20 |
Correct |
491 ms |
63488 KB |
Output is correct - L = 135502710 |
21 |
Correct |
462 ms |
63680 KB |
Output is correct - L = 135002700 |
22 |
Correct |
499 ms |
63680 KB |
Output is correct - L = 135502710 |
23 |
Correct |
480 ms |
63440 KB |
Output is correct - L = 135502710 |
24 |
Correct |
485 ms |
63168 KB |
Output is correct - L = 135002700 |
25 |
Correct |
514 ms |
63248 KB |
Output is correct - L = 134502690 |
26 |
Correct |
500 ms |
62968 KB |
Output is correct - L = 134002680 |
27 |
Correct |
531 ms |
62944 KB |
Output is correct - L = 133002660 |