# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
996896 |
2024-06-11T11:55:32 Z |
AdamGS |
City (JOI17_city) |
C++17 |
|
231 ms |
39940 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) {
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=2096736;
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;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
13084 KB |
Output is correct |
2 |
Correct |
2 ms |
13084 KB |
Output is correct |
3 |
Correct |
2 ms |
13072 KB |
Output is correct |
4 |
Correct |
2 ms |
13084 KB |
Output is correct |
5 |
Correct |
2 ms |
13068 KB |
Output is correct |
6 |
Correct |
1 ms |
13084 KB |
Output is correct |
7 |
Correct |
2 ms |
13080 KB |
Output is correct |
8 |
Correct |
2 ms |
13084 KB |
Output is correct |
9 |
Correct |
2 ms |
13080 KB |
Output is correct |
10 |
Correct |
1 ms |
13084 KB |
Output is correct |
11 |
Correct |
1 ms |
13072 KB |
Output is correct |
12 |
Correct |
2 ms |
13080 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
111 ms |
20608 KB |
Output is correct - L = 264188736 |
2 |
Correct |
95 ms |
20616 KB |
Output is correct - L = 264188736 |
3 |
Correct |
98 ms |
20652 KB |
Output is correct - L = 264188736 |
4 |
Correct |
95 ms |
20756 KB |
Output is correct - L = 266285472 |
5 |
Partially correct |
222 ms |
39056 KB |
Output is partially correct - L = 1335620832 |
6 |
Partially correct |
209 ms |
39160 KB |
Output is partially correct - L = 1335620832 |
7 |
Partially correct |
216 ms |
39052 KB |
Output is partially correct - L = 1335620832 |
8 |
Partially correct |
204 ms |
38792 KB |
Output is partially correct - L = 1432070688 |
9 |
Partially correct |
213 ms |
39676 KB |
Output is partially correct - L = 1283202432 |
10 |
Partially correct |
195 ms |
39940 KB |
Output is partially correct - L = 1289492640 |
11 |
Partially correct |
189 ms |
39892 KB |
Output is partially correct - L = 1293686112 |
12 |
Partially correct |
202 ms |
39720 KB |
Output is partially correct - L = 1293686112 |
13 |
Partially correct |
203 ms |
39428 KB |
Output is partially correct - L = 1310460000 |
14 |
Partially correct |
230 ms |
39164 KB |
Output is partially correct - L = 1327233888 |
15 |
Correct |
95 ms |
20636 KB |
Output is correct - L = 266285472 |
16 |
Correct |
95 ms |
20632 KB |
Output is correct - L = 266285472 |
17 |
Correct |
104 ms |
20636 KB |
Output is correct - L = 264188736 |
18 |
Partially correct |
205 ms |
39428 KB |
Output is partially correct - L = 1291589376 |
19 |
Partially correct |
231 ms |
39524 KB |
Output is partially correct - L = 1291589376 |
20 |
Partially correct |
210 ms |
39420 KB |
Output is partially correct - L = 1291589376 |
21 |
Partially correct |
216 ms |
39368 KB |
Output is partially correct - L = 1283202432 |
22 |
Partially correct |
211 ms |
39160 KB |
Output is partially correct - L = 1291589376 |
23 |
Partially correct |
218 ms |
39348 KB |
Output is partially correct - L = 1291589376 |
24 |
Partially correct |
202 ms |
39056 KB |
Output is partially correct - L = 1289492640 |
25 |
Partially correct |
205 ms |
39056 KB |
Output is partially correct - L = 1287395904 |
26 |
Partially correct |
211 ms |
39100 KB |
Output is partially correct - L = 1285299168 |
27 |
Partially correct |
206 ms |
39056 KB |
Output is partially correct - L = 1285299168 |