# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
996877 |
2024-06-11T11:41:32 Z |
AdamGS |
City (JOI17_city) |
C++17 |
|
252 ms |
39936 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=4096736;
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=4096736;
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 |
1 ms |
13076 KB |
Output is correct |
2 |
Correct |
2 ms |
13076 KB |
Output is correct |
3 |
Correct |
2 ms |
13072 KB |
Output is correct |
4 |
Correct |
2 ms |
13084 KB |
Output is correct |
5 |
Correct |
1 ms |
13084 KB |
Output is correct |
6 |
Correct |
1 ms |
13084 KB |
Output is correct |
7 |
Correct |
3 ms |
13072 KB |
Output is correct |
8 |
Correct |
1 ms |
13080 KB |
Output is correct |
9 |
Correct |
1 ms |
13088 KB |
Output is correct |
10 |
Correct |
2 ms |
13196 KB |
Output is correct |
11 |
Correct |
2 ms |
13084 KB |
Output is correct |
12 |
Correct |
2 ms |
13072 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
94 ms |
20644 KB |
Output is correct - L = 192546592 |
2 |
Correct |
95 ms |
20540 KB |
Output is correct - L = 200740064 |
3 |
Correct |
94 ms |
20892 KB |
Output is correct - L = 184353120 |
4 |
Correct |
108 ms |
20788 KB |
Output is correct - L = 172062912 |
5 |
Partially correct |
242 ms |
39052 KB |
Output is partially correct - L = 3617417888 |
6 |
Partially correct |
243 ms |
39500 KB |
Output is partially correct - L = 3609224416 |
7 |
Partially correct |
232 ms |
39144 KB |
Output is partially correct - L = 3629708096 |
8 |
Partially correct |
223 ms |
38900 KB |
Output is partially correct - L = 3375710464 |
9 |
Partially correct |
224 ms |
39820 KB |
Output is partially correct - L = 2281881952 |
10 |
Partially correct |
210 ms |
39724 KB |
Output is partially correct - L = 2118012512 |
11 |
Partially correct |
225 ms |
39936 KB |
Output is partially correct - L = 2118012512 |
12 |
Partially correct |
211 ms |
39936 KB |
Output is partially correct - L = 2118012512 |
13 |
Partially correct |
224 ms |
39424 KB |
Output is partially correct - L = 2867715200 |
14 |
Partially correct |
232 ms |
39440 KB |
Output is partially correct - L = 3289679008 |
15 |
Correct |
102 ms |
20720 KB |
Output is correct - L = 196643328 |
16 |
Correct |
92 ms |
20632 KB |
Output is correct - L = 192546592 |
17 |
Correct |
96 ms |
20648 KB |
Output is correct - L = 196643328 |
18 |
Partially correct |
226 ms |
39424 KB |
Output is partially correct - L = 2888198880 |
19 |
Partially correct |
216 ms |
39296 KB |
Output is partially correct - L = 2957843392 |
20 |
Partially correct |
234 ms |
39252 KB |
Output is partially correct - L = 2961940128 |
21 |
Partially correct |
218 ms |
39424 KB |
Output is partially correct - L = 2666975136 |
22 |
Partially correct |
218 ms |
39300 KB |
Output is partially correct - L = 3359323520 |
23 |
Partially correct |
252 ms |
39208 KB |
Output is partially correct - L = 3359323520 |
24 |
Partially correct |
226 ms |
39564 KB |
Output is partially correct - L = 3736223232 |
25 |
Partially correct |
218 ms |
39092 KB |
Output is partially correct - L = 4076252320 |
26 |
Partially correct |
232 ms |
39052 KB |
Output is partially correct - L = 4399894464 |
27 |
Partially correct |
230 ms |
39124 KB |
Output is partially correct - L = 4981630976 |