# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
996878 |
2024-06-11T11:42:16 Z |
AdamGS |
City (JOI17_city) |
C++17 |
|
289 ms |
39932 KB |
#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=3596736;
const int LIM=25e4+7;
vector<int>V[LIM];
ll pre[LIM], lpre;
ll rnd(ll x) {
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;
}
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)*rnd(z);
Code(x, pre[x]+K*rnd(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=3596736;
void InitDevice() {}
bool oc(ll x, ll y) {
ll a=x%K, b=y%K, c=x/K;
return a<=b && b<a+c*c;
}
int Answer(ll S, ll T) {
if(oc(S, T)) return 1;
if(oc(T, S)) return 0;
return 2;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
13252 KB |
Output is correct |
2 |
Correct |
2 ms |
13072 KB |
Output is correct |
3 |
Correct |
1 ms |
13072 KB |
Output is correct |
4 |
Correct |
2 ms |
13080 KB |
Output is correct |
5 |
Correct |
1 ms |
13072 KB |
Output is correct |
6 |
Correct |
1 ms |
13088 KB |
Output is correct |
7 |
Correct |
2 ms |
13084 KB |
Output is correct |
8 |
Correct |
2 ms |
13072 KB |
Output is correct |
9 |
Correct |
1 ms |
13068 KB |
Output is correct |
10 |
Correct |
2 ms |
13080 KB |
Output is correct |
11 |
Correct |
2 ms |
13072 KB |
Output is correct |
12 |
Correct |
3 ms |
13072 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
96 ms |
20636 KB |
Output is correct - L = 169046592 |
2 |
Correct |
94 ms |
20588 KB |
Output is correct - L = 176240064 |
3 |
Correct |
94 ms |
20644 KB |
Output is correct - L = 161853120 |
4 |
Correct |
97 ms |
20528 KB |
Output is correct - L = 151062912 |
5 |
Partially correct |
233 ms |
39164 KB |
Output is partially correct - L = 3175917888 |
6 |
Partially correct |
239 ms |
38948 KB |
Output is partially correct - L = 3168724416 |
7 |
Partially correct |
231 ms |
39052 KB |
Output is partially correct - L = 3186708096 |
8 |
Partially correct |
239 ms |
38796 KB |
Output is partially correct - L = 2963710464 |
9 |
Partially correct |
210 ms |
39620 KB |
Output is partially correct - L = 2003381952 |
10 |
Partially correct |
218 ms |
39660 KB |
Output is partially correct - L = 1859512512 |
11 |
Partially correct |
207 ms |
39720 KB |
Output is partially correct - L = 1859512512 |
12 |
Partially correct |
206 ms |
39932 KB |
Output is partially correct - L = 1859512512 |
13 |
Partially correct |
219 ms |
39360 KB |
Output is partially correct - L = 2517715200 |
14 |
Partially correct |
243 ms |
39240 KB |
Output is partially correct - L = 2888179008 |
15 |
Correct |
95 ms |
20640 KB |
Output is correct - L = 172643328 |
16 |
Correct |
97 ms |
20636 KB |
Output is correct - L = 169046592 |
17 |
Correct |
98 ms |
20548 KB |
Output is correct - L = 172643328 |
18 |
Partially correct |
222 ms |
39432 KB |
Output is partially correct - L = 2535698880 |
19 |
Partially correct |
234 ms |
39420 KB |
Output is partially correct - L = 2596843392 |
20 |
Partially correct |
220 ms |
39428 KB |
Output is partially correct - L = 2600440128 |
21 |
Partially correct |
220 ms |
39164 KB |
Output is partially correct - L = 2341475136 |
22 |
Partially correct |
260 ms |
39296 KB |
Output is partially correct - L = 2949323520 |
23 |
Partially correct |
289 ms |
39112 KB |
Output is partially correct - L = 2949323520 |
24 |
Partially correct |
226 ms |
39160 KB |
Output is partially correct - L = 3280223232 |
25 |
Partially correct |
224 ms |
39080 KB |
Output is partially correct - L = 3578752320 |
26 |
Partially correct |
246 ms |
39052 KB |
Output is partially correct - L = 3862894464 |
27 |
Partially correct |
231 ms |
39056 KB |
Output is partially correct - L = 4373630976 |