# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
996883 |
2024-06-11T11:45:05 Z |
AdamGS |
City (JOI17_city) |
C++17 |
|
245 ms |
39908 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=1096736;
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=1096736;
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 |
13084 KB |
Output is correct |
2 |
Correct |
1 ms |
13084 KB |
Output is correct |
3 |
Correct |
1 ms |
13084 KB |
Output is correct |
4 |
Correct |
2 ms |
13072 KB |
Output is correct |
5 |
Correct |
1 ms |
13076 KB |
Output is correct |
6 |
Correct |
2 ms |
13080 KB |
Output is correct |
7 |
Correct |
1 ms |
13088 KB |
Output is correct |
8 |
Correct |
1 ms |
13072 KB |
Output is correct |
9 |
Correct |
2 ms |
13168 KB |
Output is correct |
10 |
Correct |
2 ms |
13084 KB |
Output is correct |
11 |
Correct |
1 ms |
13084 KB |
Output is correct |
12 |
Correct |
1 ms |
13084 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
97 ms |
20652 KB |
Output is correct - L = 51546592 |
2 |
Correct |
103 ms |
20644 KB |
Output is correct - L = 53740064 |
3 |
Correct |
94 ms |
20656 KB |
Output is correct - L = 49353120 |
4 |
Correct |
97 ms |
20532 KB |
Output is correct - L = 46062912 |
5 |
Partially correct |
245 ms |
39052 KB |
Output is partially correct - L = 968417888 |
6 |
Partially correct |
222 ms |
39052 KB |
Output is partially correct - L = 966224416 |
7 |
Partially correct |
235 ms |
39052 KB |
Output is partially correct - L = 971708096 |
8 |
Partially correct |
234 ms |
38796 KB |
Output is partially correct - L = 903710464 |
9 |
Partially correct |
219 ms |
39644 KB |
Output is partially correct - L = 610881952 |
10 |
Partially correct |
221 ms |
39908 KB |
Output is partially correct - L = 567012512 |
11 |
Partially correct |
207 ms |
39808 KB |
Output is partially correct - L = 567012512 |
12 |
Partially correct |
211 ms |
39736 KB |
Output is partially correct - L = 567012512 |
13 |
Partially correct |
221 ms |
39388 KB |
Output is partially correct - L = 767715200 |
14 |
Partially correct |
230 ms |
39248 KB |
Output is partially correct - L = 880679008 |
15 |
Correct |
97 ms |
20636 KB |
Output is correct - L = 52643328 |
16 |
Correct |
95 ms |
20700 KB |
Output is correct - L = 51546592 |
17 |
Correct |
97 ms |
20700 KB |
Output is correct - L = 52643328 |
18 |
Partially correct |
226 ms |
39588 KB |
Output is partially correct - L = 773198880 |
19 |
Partially correct |
228 ms |
39364 KB |
Output is partially correct - L = 791843392 |
20 |
Partially correct |
224 ms |
39364 KB |
Output is partially correct - L = 792940128 |
21 |
Partially correct |
220 ms |
39224 KB |
Output is partially correct - L = 713975136 |
22 |
Partially correct |
219 ms |
39300 KB |
Output is partially correct - L = 899323520 |
23 |
Partially correct |
217 ms |
39276 KB |
Output is partially correct - L = 899323520 |
24 |
Partially correct |
237 ms |
39308 KB |
Output is partially correct - L = 1000223232 |
25 |
Partially correct |
227 ms |
39056 KB |
Output is partially correct - L = 1091252320 |
26 |
Partially correct |
241 ms |
39028 KB |
Output is partially correct - L = 1177894464 |
27 |
Incorrect |
227 ms |
39064 KB |
Wrong Answer [6] |
28 |
Halted |
0 ms |
0 KB |
- |