#include "Encoder.h"
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(a, b) for(int a = 0; a < (b); ++a)
#define st first
#define nd second
#define pb push_back
#define all(a) a.begin(), a.end()
const ll K=1096736;
const int LIM=25e4+7;
vector<int>V[LIM];
ll pre[LIM], lpre;
ll rnd(ll x) {
if(x<=100) return x;
x-=100;
ll po=0, ko=1000000000;
while(po<ko) {
ll sr=(po+ko)/2;
if(sr*sr<x) po=sr+1; else ko=sr;
}
return po*po+100;
}
ll cod(ll x) {
if(x<=100) return x;
x-=100;
ll po=0, ko=1000000000;
while(po<ko) {
ll sr=(po+ko)/2;
if(sr*sr<x) po=sr+1; else ko=sr;
}
return po+100;
}
void DFS(int x, int o) {
pre[x]=lpre; ++lpre;
for(auto i : V[x]) if(i!=o) DFS(i, x);
ll z=lpre-pre[x];
lpre=pre[x]+rnd(z);
Code(x, pre[x]+K*cod(z));
}
void Encode(int n, int A[], int B[]) {
rep(i, n-1) {
V[A[i]].pb(B[i]);
V[B[i]].pb(A[i]);
}
DFS(0, 0);
}
#include "Device.h"
#include<bits/stdc++.h>
typedef long long ll;
#define rep(a, b) for(int a = 0; a < (b); ++a)
#define st first
#define nd second
#define pb push_back
#define all(a) a.begin(), a.end()
const ll K=1096736;
void InitDevice() {}
ll dec(ll x) {
if(x<=100) return x;
x-=100;
return x*x+100;
}
bool oc(ll x, ll y) {
ll a=x%K, b=y%K, c=x/K;
return a<=b && b<a+dec(c);
}
int Answer(ll S, ll T) {
if(oc(S, T)) return 1;
if(oc(T, S)) return 0;
return 2;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
13072 KB |
Output is correct |
2 |
Correct |
2 ms |
13084 KB |
Output is correct |
3 |
Correct |
2 ms |
13080 KB |
Output is correct |
4 |
Correct |
2 ms |
13080 KB |
Output is correct |
5 |
Correct |
1 ms |
13076 KB |
Output is correct |
6 |
Correct |
1 ms |
13084 KB |
Output is correct |
7 |
Correct |
2 ms |
13072 KB |
Output is correct |
8 |
Correct |
1 ms |
13080 KB |
Output is correct |
9 |
Correct |
2 ms |
13080 KB |
Output is correct |
10 |
Correct |
1 ms |
13084 KB |
Output is correct |
11 |
Correct |
2 ms |
13084 KB |
Output is correct |
12 |
Correct |
2 ms |
13072 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
98 ms |
20636 KB |
Output is correct - L = 138188736 |
2 |
Correct |
93 ms |
20644 KB |
Output is correct - L = 138188736 |
3 |
Correct |
97 ms |
20560 KB |
Output is correct - L = 138188736 |
4 |
Correct |
97 ms |
20900 KB |
Output is correct - L = 139285472 |
5 |
Partially correct |
220 ms |
39160 KB |
Output is partially correct - L = 698620832 |
6 |
Partially correct |
210 ms |
39056 KB |
Output is partially correct - L = 698620832 |
7 |
Partially correct |
213 ms |
39048 KB |
Output is partially correct - L = 698620832 |
8 |
Partially correct |
212 ms |
38748 KB |
Output is partially correct - L = 749070688 |
9 |
Partially correct |
194 ms |
39620 KB |
Output is partially correct - L = 671202432 |
10 |
Partially correct |
192 ms |
39896 KB |
Output is partially correct - L = 674492640 |
11 |
Partially correct |
188 ms |
39716 KB |
Output is partially correct - L = 676686112 |
12 |
Partially correct |
195 ms |
39952 KB |
Output is partially correct - L = 676686112 |
13 |
Partially correct |
197 ms |
39372 KB |
Output is partially correct - L = 685460000 |
14 |
Partially correct |
214 ms |
39308 KB |
Output is partially correct - L = 694233888 |
15 |
Correct |
107 ms |
20648 KB |
Output is correct - L = 139285472 |
16 |
Correct |
95 ms |
20632 KB |
Output is correct - L = 139285472 |
17 |
Correct |
98 ms |
20644 KB |
Output is correct - L = 138188736 |
18 |
Partially correct |
209 ms |
39372 KB |
Output is partially correct - L = 675589376 |
19 |
Partially correct |
216 ms |
39432 KB |
Output is partially correct - L = 675589376 |
20 |
Partially correct |
207 ms |
39428 KB |
Output is partially correct - L = 675589376 |
21 |
Partially correct |
212 ms |
39220 KB |
Output is partially correct - L = 671202432 |
22 |
Partially correct |
206 ms |
39300 KB |
Output is partially correct - L = 675589376 |
23 |
Partially correct |
202 ms |
39324 KB |
Output is partially correct - L = 675589376 |
24 |
Partially correct |
206 ms |
39416 KB |
Output is partially correct - L = 674492640 |
25 |
Partially correct |
211 ms |
39052 KB |
Output is partially correct - L = 673395904 |
26 |
Partially correct |
217 ms |
39416 KB |
Output is partially correct - L = 672299168 |
27 |
Partially correct |
216 ms |
39048 KB |
Output is partially correct - L = 672299168 |