Submission #26904

# Submission time Handle Problem Language Result Execution time Memory
26904 2017-07-07T06:12:53 Z wangyenjen City (JOI17_city) C++14
97 / 100
526 ms 56592 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 <= 18 * 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 <= 18 * 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 9 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 12544 KB Output is correct
5 Correct 9 ms 12544 KB Output is correct
6 Correct 9 ms 12544 KB Output is correct
7 Correct 8 ms 12544 KB Output is correct
8 Correct 7 ms 12288 KB Output is correct
9 Correct 8 ms 12544 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
# Verdict Execution time Memory Grader output
1 Correct 173 ms 19608 KB Output is correct - L = 313820
2 Correct 173 ms 19440 KB Output is correct - L = 326316
3 Correct 174 ms 19432 KB Output is correct - L = 319216
4 Correct 173 ms 19448 KB Output is correct - L = 318080
5 Correct 495 ms 55256 KB Output is correct - L = 128023224
6 Correct 511 ms 55296 KB Output is correct - L = 130443472
7 Correct 475 ms 55272 KB Output is correct - L = 131215384
8 Correct 505 ms 54624 KB Output is correct - L = 146496288
9 Partially correct 425 ms 56576 KB Output is partially correct - L = 293134576
10 Partially correct 417 ms 56592 KB Output is partially correct - L = 290881604
11 Partially correct 427 ms 56560 KB Output is partially correct - L = 320620948
12 Partially correct 406 ms 56528 KB Output is partially correct - L = 290815716
13 Correct 475 ms 56184 KB Output is correct - L = 202471836
14 Correct 490 ms 55536 KB Output is correct - L = 154611020
15 Correct 181 ms 19440 KB Output is correct - L = 319500
16 Correct 200 ms 19448 KB Output is correct - L = 326316
17 Correct 179 ms 19520 KB Output is correct - L = 306720
18 Correct 470 ms 55520 KB Output is correct - L = 227861436
19 Correct 482 ms 55704 KB Output is correct - L = 106675796
20 Correct 506 ms 55544 KB Output is correct - L = 106513916
21 Correct 487 ms 55696 KB Output is correct - L = 239255232
22 Correct 505 ms 55544 KB Output is correct - L = 101748680
23 Correct 494 ms 55616 KB Output is correct - L = 99835656
24 Correct 520 ms 55280 KB Output is correct - L = 97497200
25 Correct 511 ms 55392 KB Output is correct - L = 94451300
26 Correct 526 ms 55384 KB Output is correct - L = 92149196
27 Correct 514 ms 54992 KB Output is correct - L = 92352540