# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
996880 |
2024-06-11T11:43:33 Z |
AdamGS |
City (JOI17_city) |
C++17 |
|
275 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=2096736;
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=2096736;
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 |
13068 KB |
Output is correct |
2 |
Correct |
1 ms |
13072 KB |
Output is correct |
3 |
Correct |
1 ms |
13084 KB |
Output is correct |
4 |
Correct |
1 ms |
13084 KB |
Output is correct |
5 |
Correct |
2 ms |
13072 KB |
Output is correct |
6 |
Correct |
2 ms |
13072 KB |
Output is correct |
7 |
Correct |
1 ms |
13072 KB |
Output is correct |
8 |
Correct |
1 ms |
13084 KB |
Output is correct |
9 |
Correct |
2 ms |
13072 KB |
Output is correct |
10 |
Correct |
2 ms |
13084 KB |
Output is correct |
11 |
Correct |
1 ms |
13072 KB |
Output is correct |
12 |
Correct |
2 ms |
13084 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
97 ms |
20656 KB |
Output is correct - L = 98546592 |
2 |
Correct |
93 ms |
20624 KB |
Output is correct - L = 102740064 |
3 |
Correct |
99 ms |
20640 KB |
Output is correct - L = 94353120 |
4 |
Correct |
93 ms |
20636 KB |
Output is correct - L = 88062912 |
5 |
Partially correct |
249 ms |
39164 KB |
Output is partially correct - L = 1851417888 |
6 |
Partially correct |
230 ms |
39248 KB |
Output is partially correct - L = 1847224416 |
7 |
Partially correct |
235 ms |
39188 KB |
Output is partially correct - L = 1857708096 |
8 |
Partially correct |
250 ms |
38704 KB |
Output is partially correct - L = 1727710464 |
9 |
Partially correct |
227 ms |
39648 KB |
Output is partially correct - L = 1167881952 |
10 |
Partially correct |
257 ms |
39932 KB |
Output is partially correct - L = 1084012512 |
11 |
Partially correct |
245 ms |
39936 KB |
Output is partially correct - L = 1084012512 |
12 |
Partially correct |
238 ms |
39796 KB |
Output is partially correct - L = 1084012512 |
13 |
Partially correct |
247 ms |
39428 KB |
Output is partially correct - L = 1467715200 |
14 |
Partially correct |
275 ms |
39412 KB |
Output is partially correct - L = 1683679008 |
15 |
Correct |
132 ms |
20752 KB |
Output is correct - L = 100643328 |
16 |
Correct |
94 ms |
20632 KB |
Output is correct - L = 98546592 |
17 |
Correct |
94 ms |
20648 KB |
Output is correct - L = 100643328 |
18 |
Partially correct |
239 ms |
39112 KB |
Output is partially correct - L = 1478198880 |
19 |
Partially correct |
239 ms |
39240 KB |
Output is partially correct - L = 1513843392 |
20 |
Partially correct |
228 ms |
39368 KB |
Output is partially correct - L = 1515940128 |
21 |
Partially correct |
263 ms |
39428 KB |
Output is partially correct - L = 1364975136 |
22 |
Partially correct |
235 ms |
39144 KB |
Output is partially correct - L = 1719323520 |
23 |
Partially correct |
227 ms |
39296 KB |
Output is partially correct - L = 1719323520 |
24 |
Partially correct |
225 ms |
39032 KB |
Output is partially correct - L = 1912223232 |
25 |
Partially correct |
239 ms |
39028 KB |
Output is partially correct - L = 2086252320 |
26 |
Partially correct |
223 ms |
39108 KB |
Output is partially correct - L = 2251894464 |
27 |
Partially correct |
252 ms |
39160 KB |
Output is partially correct - L = 2549630976 |