Submission #26911

# Submission time Handle Problem Language Result Execution time Memory
26911 2017-07-07T06:20:52 Z wangyenjen City (JOI17_city) C++14
98 / 100
522 ms 56784 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 <= 5 * 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 <= 5 * 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 12544 KB Output is correct
2 Correct 8 ms 12544 KB Output is correct
3 Correct 9 ms 12544 KB Output is correct
4 Correct 9 ms 12288 KB Output is correct
5 Correct 9 ms 12544 KB Output is correct
6 Correct 8 ms 12544 KB Output is correct
7 Correct 16 ms 12288 KB Output is correct
8 Correct 9 ms 12544 KB Output is correct
9 Correct 9 ms 12544 KB Output is correct
10 Correct 9 ms 12544 KB Output is correct
11 Correct 9 ms 12544 KB Output is correct
12 Correct 9 ms 12552 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 181 ms 19400 KB Output is correct - L = 285090
2 Correct 174 ms 19504 KB Output is correct - L = 296442
3 Correct 174 ms 19416 KB Output is correct - L = 289992
4 Correct 177 ms 19432 KB Output is correct - L = 288960
5 Correct 515 ms 55152 KB Output is correct - L = 116302788
6 Correct 522 ms 55152 KB Output is correct - L = 118501464
7 Correct 497 ms 55536 KB Output is correct - L = 119202708
8 Correct 521 ms 54720 KB Output is correct - L = 133084656
9 Correct 446 ms 56504 KB Output is correct - L = 266298312
10 Correct 423 ms 56616 KB Output is correct - L = 264251598
11 Partially correct 415 ms 56720 KB Output is partially correct - L = 291268326
12 Correct 432 ms 56784 KB Output is correct - L = 264191742
13 Correct 475 ms 56128 KB Output is correct - L = 183935682
14 Correct 508 ms 55608 KB Output is correct - L = 140456490
15 Correct 177 ms 19632 KB Output is correct - L = 290250
16 Correct 175 ms 19328 KB Output is correct - L = 296442
17 Correct 177 ms 19448 KB Output is correct - L = 278640
18 Correct 510 ms 55488 KB Output is correct - L = 207000882
19 Correct 502 ms 55704 KB Output is correct - L = 96909702
20 Correct 487 ms 55704 KB Output is correct - L = 96762642
21 Correct 481 ms 55776 KB Output is correct - L = 217351584
22 Correct 520 ms 55472 KB Output is correct - L = 92433660
23 Correct 511 ms 55760 KB Output is correct - L = 90695772
24 Correct 517 ms 55528 KB Output is correct - L = 88571400
25 Correct 519 ms 55352 KB Output is correct - L = 85804350
26 Correct 521 ms 55136 KB Output is correct - L = 83713002
27 Correct 516 ms 55080 KB Output is correct - L = 83897730