답안 #26903

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
26903 2017-07-07T06:11:28 Z wangyenjen City (JOI17_city) C++14
97 / 100
575 ms 56736 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 <= 19 * 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 <= 19 * 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;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 41 ms 12376 KB Output is correct
2 Correct 8 ms 12288 KB Output is correct
3 Correct 9 ms 12544 KB Output is correct
4 Correct 8 ms 12488 KB Output is correct
5 Correct 9 ms 12544 KB Output is correct
6 Correct 8 ms 12544 KB Output is correct
7 Correct 9 ms 12544 KB Output is correct
8 Correct 9 ms 12288 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 8 ms 12288 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 176 ms 19448 KB Output is correct - L = 314925
2 Correct 173 ms 19440 KB Output is correct - L = 327465
3 Correct 173 ms 19384 KB Output is correct - L = 320340
4 Correct 175 ms 19592 KB Output is correct - L = 319200
5 Correct 511 ms 55544 KB Output is correct - L = 128474010
6 Correct 559 ms 55272 KB Output is correct - L = 130902780
7 Correct 499 ms 55280 KB Output is correct - L = 131677410
8 Correct 538 ms 54752 KB Output is correct - L = 147012120
9 Partially correct 437 ms 56456 KB Output is partially correct - L = 294166740
10 Partially correct 441 ms 56736 KB Output is partially correct - L = 291905835
11 Partially correct 428 ms 56560 KB Output is partially correct - L = 321749895
12 Partially correct 422 ms 56648 KB Output is partially correct - L = 291839715
13 Correct 453 ms 55880 KB Output is correct - L = 203184765
14 Correct 471 ms 55456 KB Output is correct - L = 155155425
15 Correct 174 ms 19736 KB Output is correct - L = 320625
16 Correct 177 ms 19544 KB Output is correct - L = 327465
17 Correct 175 ms 19440 KB Output is correct - L = 307800
18 Correct 485 ms 55640 KB Output is correct - L = 228663765
19 Correct 472 ms 55696 KB Output is correct - L = 107051415
20 Correct 462 ms 55712 KB Output is correct - L = 106888965
21 Correct 484 ms 55640 KB Output is correct - L = 240097680
22 Correct 532 ms 55440 KB Output is correct - L = 102106950
23 Correct 575 ms 55704 KB Output is correct - L = 100187190
24 Correct 542 ms 55328 KB Output is correct - L = 97840500
25 Correct 530 ms 55264 KB Output is correct - L = 94783875
26 Correct 534 ms 55336 KB Output is correct - L = 92473665
27 Correct 541 ms 55224 KB Output is correct - L = 92677725