Submission #26909

# Submission time Handle Problem Language Result Execution time Memory
26909 2017-07-07T06:16:52 Z wangyenjen City (JOI17_city) C++14
98 / 100
558 ms 56696 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 <= 7 * 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 <= 7 * 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 12288 KB Output is correct
3 Correct 7 ms 12544 KB Output is correct
4 Correct 8 ms 12544 KB Output is correct
5 Correct 8 ms 12544 KB Output is correct
6 Correct 9 ms 12488 KB Output is correct
7 Correct 7 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 7 ms 12544 KB Output is correct
12 Correct 9 ms 12544 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 176 ms 19376 KB Output is correct - L = 291720
2 Correct 172 ms 19536 KB Output is correct - L = 303336
3 Correct 174 ms 19408 KB Output is correct - L = 296736
4 Correct 177 ms 19800 KB Output is correct - L = 295680
5 Correct 505 ms 55280 KB Output is correct - L = 119007504
6 Correct 496 ms 55536 KB Output is correct - L = 121257312
7 Correct 520 ms 55664 KB Output is correct - L = 121974864
8 Correct 490 ms 54616 KB Output is correct - L = 136179648
9 Partially correct 432 ms 56528 KB Output is partially correct - L = 272491296
10 Partially correct 435 ms 56664 KB Output is partially correct - L = 270396984
11 Partially correct 415 ms 56632 KB Output is partially correct - L = 298042008
12 Partially correct 422 ms 56696 KB Output is partially correct - L = 270335736
13 Correct 455 ms 55896 KB Output is correct - L = 188213256
14 Correct 481 ms 55656 KB Output is correct - L = 143722920
15 Correct 177 ms 19440 KB Output is correct - L = 297000
16 Correct 177 ms 19360 KB Output is correct - L = 303336
17 Correct 172 ms 19440 KB Output is correct - L = 285120
18 Correct 493 ms 55680 KB Output is correct - L = 211814856
19 Correct 511 ms 55768 KB Output is correct - L = 99163416
20 Correct 487 ms 55616 KB Output is correct - L = 99012936
21 Correct 476 ms 55776 KB Output is correct - L = 222406272
22 Correct 502 ms 55624 KB Output is correct - L = 94583280
23 Correct 496 ms 55472 KB Output is correct - L = 92804976
24 Correct 502 ms 55336 KB Output is correct - L = 90631200
25 Correct 509 ms 55296 KB Output is correct - L = 87799800
26 Correct 558 ms 55256 KB Output is correct - L = 85659816
27 Correct 537 ms 55032 KB Output is correct - L = 85848840