답안 #26916

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
26916 2017-07-07T06:26:56 Z wangyenjen City (JOI17_city) C++14
98 / 100
608 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 <= 4.87 * 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 <= 4.87 * 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 9 ms 12544 KB Output is correct
2 Correct 8 ms 12544 KB Output is correct
3 Correct 8 ms 12544 KB Output is correct
4 Correct 9 ms 12544 KB Output is correct
5 Correct 8 ms 12288 KB Output is correct
6 Correct 8 ms 12544 KB Output is correct
7 Correct 9 ms 12544 KB Output is correct
8 Correct 8 ms 12544 KB Output is correct
9 Correct 9 ms 12288 KB Output is correct
10 Correct 8 ms 12544 KB Output is correct
11 Correct 8 ms 12544 KB Output is correct
12 Correct 8 ms 12544 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 169 ms 19440 KB Output is correct - L = 283985
2 Correct 168 ms 19464 KB Output is correct - L = 295293
3 Correct 170 ms 19440 KB Output is correct - L = 288868
4 Correct 172 ms 19384 KB Output is correct - L = 287840
5 Correct 512 ms 55216 KB Output is correct - L = 115852002
6 Correct 484 ms 55240 KB Output is correct - L = 118042156
7 Correct 491 ms 55280 KB Output is correct - L = 118740682
8 Correct 520 ms 54568 KB Output is correct - L = 132568824
9 Correct 434 ms 56576 KB Output is correct - L = 265266148
10 Correct 424 ms 56704 KB Output is correct - L = 263227367
11 Partially correct 420 ms 56736 KB Output is partially correct - L = 290139379
12 Correct 417 ms 56496 KB Output is correct - L = 263167743
13 Correct 452 ms 56056 KB Output is correct - L = 183222753
14 Correct 468 ms 55544 KB Output is correct - L = 139912085
15 Correct 172 ms 19496 KB Output is correct - L = 289125
16 Correct 172 ms 19440 KB Output is correct - L = 295293
17 Correct 173 ms 19504 KB Output is correct - L = 277560
18 Correct 487 ms 55608 KB Output is correct - L = 206198553
19 Correct 487 ms 55688 KB Output is correct - L = 96534083
20 Correct 494 ms 55600 KB Output is correct - L = 96387593
21 Correct 492 ms 55792 KB Output is correct - L = 216509136
22 Correct 498 ms 55568 KB Output is correct - L = 92075390
23 Correct 505 ms 55600 KB Output is correct - L = 90344238
24 Correct 506 ms 55424 KB Output is correct - L = 88228100
25 Correct 527 ms 55336 KB Output is correct - L = 85471775
26 Correct 524 ms 55136 KB Output is correct - L = 83388533
27 Correct 608 ms 55480 KB Output is correct - L = 83572545