#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=496736;
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=496736;
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 |
1 ms |
13072 KB |
Output is correct |
2 |
Correct |
1 ms |
13068 KB |
Output is correct |
3 |
Correct |
2 ms |
13068 KB |
Output is correct |
4 |
Correct |
2 ms |
13068 KB |
Output is correct |
5 |
Correct |
2 ms |
13076 KB |
Output is correct |
6 |
Correct |
2 ms |
13068 KB |
Output is correct |
7 |
Correct |
2 ms |
13084 KB |
Output is correct |
8 |
Correct |
1 ms |
13072 KB |
Output is correct |
9 |
Correct |
1 ms |
13084 KB |
Output is correct |
10 |
Correct |
1 ms |
13084 KB |
Output is correct |
11 |
Correct |
3 ms |
13204 KB |
Output is correct |
12 |
Correct |
2 ms |
13072 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
99 ms |
20700 KB |
Output is correct - L = 62588736 |
2 |
Correct |
113 ms |
20520 KB |
Output is correct - L = 62588736 |
3 |
Correct |
114 ms |
20632 KB |
Output is correct - L = 62588736 |
4 |
Correct |
97 ms |
20636 KB |
Output is correct - L = 63085472 |
5 |
Partially correct |
210 ms |
39088 KB |
Output is partially correct - L = 316420832 |
6 |
Partially correct |
203 ms |
39048 KB |
Output is partially correct - L = 316420832 |
7 |
Partially correct |
207 ms |
39052 KB |
Output is partially correct - L = 316420832 |
8 |
Partially correct |
216 ms |
38900 KB |
Output is partially correct - L = 339270688 |
9 |
Partially correct |
195 ms |
39676 KB |
Output is partially correct - L = 304002432 |
10 |
Partially correct |
200 ms |
40068 KB |
Output is partially correct - L = 305492640 |
11 |
Partially correct |
194 ms |
39936 KB |
Output is partially correct - L = 306486112 |
12 |
Partially correct |
202 ms |
39808 KB |
Output is partially correct - L = 306486112 |
13 |
Partially correct |
199 ms |
39440 KB |
Output is partially correct - L = 310460000 |
14 |
Partially correct |
207 ms |
39292 KB |
Output is partially correct - L = 314433888 |
15 |
Correct |
100 ms |
20856 KB |
Output is correct - L = 63085472 |
16 |
Correct |
93 ms |
20644 KB |
Output is correct - L = 63085472 |
17 |
Correct |
98 ms |
20636 KB |
Output is correct - L = 62588736 |
18 |
Partially correct |
205 ms |
39424 KB |
Output is partially correct - L = 305989376 |
19 |
Partially correct |
201 ms |
39388 KB |
Output is partially correct - L = 305989376 |
20 |
Partially correct |
210 ms |
39400 KB |
Output is partially correct - L = 305989376 |
21 |
Partially correct |
239 ms |
39216 KB |
Output is partially correct - L = 304002432 |
22 |
Partially correct |
228 ms |
39136 KB |
Output is partially correct - L = 305989376 |
23 |
Partially correct |
199 ms |
39296 KB |
Output is partially correct - L = 305989376 |
24 |
Partially correct |
215 ms |
39404 KB |
Output is partially correct - L = 305492640 |
25 |
Partially correct |
208 ms |
39056 KB |
Output is partially correct - L = 304995904 |
26 |
Partially correct |
221 ms |
38984 KB |
Output is partially correct - L = 304499168 |
27 |
Partially correct |
213 ms |
39168 KB |
Output is partially correct - L = 304499168 |