답안 #26924

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
26924 2017-07-07T06:41:00 Z wangyenjen City (JOI17_city) C++14
8 / 100
502 ms 56648 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;

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((int)table.size() < 243) {
        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;

static vector<int> table;

static void build_table() {
    int x = 1;
    table.push_back(x);
    int cnt = 0;
    while((int)table.size() < 243) {
        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;
}

Compilation message

Device.cpp: In function 'void build_table()':
Device.cpp:16:9: warning: unused variable 'cnt' [-Wunused-variable]
     int cnt = 0;
         ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 12544 KB Output is correct
2 Correct 8 ms 12544 KB Output is correct
3 Correct 8 ms 12288 KB Output is correct
4 Correct 7 ms 12288 KB Output is correct
5 Correct 8 ms 12288 KB Output is correct
6 Correct 8 ms 12288 KB Output is correct
7 Correct 9 ms 12800 KB Output is correct
8 Correct 8 ms 12544 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 9 ms 12288 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 170 ms 19560 KB Output is correct - L = 268515
2 Correct 168 ms 19440 KB Output is correct - L = 279207
3 Correct 169 ms 19432 KB Output is correct - L = 273132
4 Correct 167 ms 19384 KB Output is correct - L = 272160
5 Correct 500 ms 55248 KB Output is correct - L = 109540998
6 Correct 502 ms 55280 KB Output is correct - L = 111611844
7 Correct 480 ms 55120 KB Output is correct - L = 112272318
8 Correct 477 ms 54752 KB Output is correct - L = 125347176
9 Incorrect 408 ms 56648 KB Wrong Answer [6]
10 Halted 0 ms 0 KB -