# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
26910 |
2017-07-07T06:17:55 Z |
wangyenjen |
City (JOI17_city) |
C++14 |
|
541 ms |
56840 KB |
/// Author: Wang, Yen-Jen
#include "Encoder.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
static const int MAX_N = 250000 + 7;
static int dfs_clock;
static vector<int> table;
static vector<int> G[MAX_N];
static int lb[MAX_N] , rb[MAX_N];
static void build_table() {
int x = 1;
table.push_back(x);
while(x <= 6 * MAX_N) {
int x2 = x * 1.05;
if(x2 == x) x2++;
table.push_back(x2);
x = x2;
}
}
static void dfs(int u , int fa) {
lb[u] = ++dfs_clock;
for(int v : G[u]) {
if(v != fa) dfs(v , u);
}
dfs_clock = rb[u] = lb[u] + *lower_bound(table.begin() , table.end() , dfs_clock - lb[u]);
}
void Encode(int N , int A[] , int B[]) {
build_table();
for(int i = 0; i < N; i++) G[i].clear();
for(int i = 0; i < N - 1; i++) {
G[A[i]].push_back(B[i]);
G[B[i]].push_back(A[i]);
}
dfs_clock = 0;
dfs(0 , -1);
for(int i = 0; i < N; i++) {
int x = lower_bound(table.begin() , table.end() , rb[i] - lb[i]) - table.begin();
Code(i , (ll)lb[i] * (int)table.size() + x);
}
}
/// Author: Wang, Yen-Jen
#include "Device.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
static const int MAX_N = 250000 + 7;
static vector<int> table;
static void build_table() {
int x = 1;
table.push_back(x);
while(x <= 6 * MAX_N) {
int x2 = x * 1.05;
if(x2 == x) x2++;
table.push_back(x2);
x = x2;
}
}
void InitDevice() {
build_table();
}
int Answer(long long S , long long T) {
int sl = S / (int)table.size();
int sr = sl + table[S % (int)table.size()];
int tl = T / (int)table.size();
int tr = tl + table[T % (int)table.size()];
if(tl <= sl && sr <= tr) return 0;
else if(sl <= tl && tr <= sr) return 1;
else return 2;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
12288 KB |
Output is correct |
2 |
Correct |
8 ms |
12544 KB |
Output is correct |
3 |
Correct |
8 ms |
12288 KB |
Output is correct |
4 |
Correct |
7 ms |
12288 KB |
Output is correct |
5 |
Correct |
7 ms |
12544 KB |
Output is correct |
6 |
Correct |
8 ms |
12544 KB |
Output is correct |
7 |
Correct |
8 ms |
12368 KB |
Output is correct |
8 |
Correct |
8 ms |
12544 KB |
Output is correct |
9 |
Correct |
8 ms |
12320 KB |
Output is correct |
10 |
Correct |
8 ms |
12544 KB |
Output is correct |
11 |
Correct |
8 ms |
12288 KB |
Output is correct |
12 |
Correct |
8 ms |
12544 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
174 ms |
19560 KB |
Output is correct - L = 288405 |
2 |
Correct |
178 ms |
19656 KB |
Output is correct - L = 299889 |
3 |
Correct |
177 ms |
19440 KB |
Output is correct - L = 293364 |
4 |
Correct |
178 ms |
19320 KB |
Output is correct - L = 292320 |
5 |
Correct |
517 ms |
55320 KB |
Output is correct - L = 117655146 |
6 |
Correct |
523 ms |
55264 KB |
Output is correct - L = 119879388 |
7 |
Correct |
505 ms |
55440 KB |
Output is correct - L = 120588786 |
8 |
Correct |
516 ms |
54752 KB |
Output is correct - L = 134632152 |
9 |
Partially correct |
439 ms |
56792 KB |
Output is partially correct - L = 269394804 |
10 |
Correct |
419 ms |
56840 KB |
Output is correct - L = 267324291 |
11 |
Partially correct |
422 ms |
56784 KB |
Output is partially correct - L = 294655167 |
12 |
Correct |
422 ms |
56568 KB |
Output is correct - L = 267263739 |
13 |
Correct |
465 ms |
56280 KB |
Output is correct - L = 186074469 |
14 |
Correct |
494 ms |
55536 KB |
Output is correct - L = 142089705 |
15 |
Correct |
172 ms |
19440 KB |
Output is correct - L = 293625 |
16 |
Correct |
174 ms |
19344 KB |
Output is correct - L = 299889 |
17 |
Correct |
175 ms |
19440 KB |
Output is correct - L = 281880 |
18 |
Correct |
528 ms |
55584 KB |
Output is correct - L = 209407869 |
19 |
Correct |
497 ms |
55712 KB |
Output is correct - L = 98036559 |
20 |
Correct |
510 ms |
55904 KB |
Output is correct - L = 97887789 |
21 |
Correct |
477 ms |
55720 KB |
Output is correct - L = 219878928 |
22 |
Correct |
521 ms |
55720 KB |
Output is correct - L = 93508470 |
23 |
Correct |
491 ms |
55592 KB |
Output is correct - L = 91750374 |
24 |
Correct |
490 ms |
55280 KB |
Output is correct - L = 89601300 |
25 |
Correct |
491 ms |
55536 KB |
Output is correct - L = 86802075 |
26 |
Correct |
541 ms |
55560 KB |
Output is correct - L = 84686409 |
27 |
Correct |
502 ms |
55264 KB |
Output is correct - L = 84873285 |