Submission #26905

# Submission time Handle Problem Language Result Execution time Memory
26905 2017-07-07T06:14:12 Z wangyenjen City (JOI17_city) C++14
97 / 100
526 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 <= 15 * 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 <= 15 * 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 12384 KB Output is correct
2 Correct 9 ms 12544 KB Output is correct
3 Correct 8 ms 12440 KB Output is correct
4 Correct 8 ms 12392 KB Output is correct
5 Correct 8 ms 12544 KB Output is correct
6 Correct 9 ms 12432 KB Output is correct
7 Correct 9 ms 12544 KB Output is correct
8 Correct 7 ms 12544 KB Output is correct
9 Correct 8 ms 12544 KB Output is correct
10 Correct 9 ms 12544 KB Output is correct
11 Correct 8 ms 12288 KB Output is correct
12 Correct 8 ms 12488 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 173 ms 19368 KB Output is correct - L = 309400
2 Correct 172 ms 19288 KB Output is correct - L = 321720
3 Correct 177 ms 19440 KB Output is correct - L = 314720
4 Correct 169 ms 19384 KB Output is correct - L = 313600
5 Correct 510 ms 55256 KB Output is correct - L = 126220080
6 Correct 478 ms 55280 KB Output is correct - L = 128606240
7 Correct 483 ms 55272 KB Output is correct - L = 129367280
8 Correct 484 ms 54768 KB Output is correct - L = 144432960
9 Partially correct 435 ms 56528 KB Output is partially correct - L = 289005920
10 Partially correct 434 ms 56776 KB Output is partially correct - L = 286784680
11 Partially correct 429 ms 56784 KB Output is partially correct - L = 316105160
12 Partially correct 424 ms 56680 KB Output is partially correct - L = 286719720
13 Correct 455 ms 55920 KB Output is correct - L = 199620120
14 Correct 486 ms 55592 KB Output is correct - L = 152433400
15 Correct 190 ms 19440 KB Output is correct - L = 315000
16 Correct 180 ms 19544 KB Output is correct - L = 321720
17 Correct 181 ms 19344 KB Output is correct - L = 302400
18 Correct 484 ms 55816 KB Output is correct - L = 224652120
19 Correct 499 ms 55656 KB Output is correct - L = 105173320
20 Correct 492 ms 55720 KB Output is correct - L = 105013720
21 Correct 503 ms 55760 KB Output is correct - L = 235885440
22 Correct 523 ms 55448 KB Output is correct - L = 100315600
23 Correct 514 ms 55520 KB Output is correct - L = 98429520
24 Correct 511 ms 55768 KB Output is correct - L = 96124000
25 Correct 489 ms 55536 KB Output is correct - L = 93121000
26 Correct 526 ms 55224 KB Output is correct - L = 90851320
27 Correct 525 ms 55256 KB Output is correct - L = 91051800