Submission #699297

# Submission time Handle Problem Language Result Execution time Memory
699297 2023-02-16T13:38:42 Z tengiz05 City (JOI17_city) C++17
8 / 100
153 ms 12296 KB
#include "Encoder.h"
#include <cmath>
#include <vector>
#include <algorithm>

constexpr int N = 250000;

// complementing subtree sizes and using much smaller numbers denoting the size

void Encode(int n, int A[], int B[]) {
    std::vector<int> f{1};
    int cur = 1;
    while (cur < N) {
        cur = std::ceil(cur * 1.05);
        f.push_back(cur);
    }
    std::vector<std::vector<int>> e(n);
    for (int i = 0; i < n - 1; i++) {
        e[A[i]].push_back(B[i]);
        e[B[i]].push_back(A[i]);
    }
	std::vector<int> in(n), siz(n);
    int timeStamp = 0;
    std::function<void(int, int)> dfs = [&](int u, int p) {
        in[u] = timeStamp++;
        siz[u] = 1;
        for (int v : e[u]) {
            if (v != p) {
                dfs(v, u);
                siz[u] += f[siz[v]];
            }
        }
        siz[u] = std::lower_bound(f.begin(), f.end(), siz[u]) - f.begin();
    };
    dfs(0, -1);
    for (int i = 0; i < n; i++) {
        Code(i, in[i] + siz[i] * 1LL * N);
    }
}
#include "Device.h"
#include <cmath>
#include <vector>

constexpr int N = 250000;
std::vector<int> f;

void InitDevice() {
    f = {1};
    int cur = 1;
    while (cur < N) {
        cur = std::ceil(cur * 1.05);
        f.push_back(cur);
    }
}

int Answer(long long S, long long T) {
	int ina = S % N;
    int outa = ina + f[S / N];
    int inb = T % N;
    int outb = inb + f[T / N];
    if (inb <= ina && ina < outb) {
        return 0;
    } else if (ina <= inb && inb < outa) {
        return 1;
    } else {
        return 2;
    }
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 528 KB Output is correct
2 Correct 0 ms 520 KB Output is correct
3 Correct 0 ms 524 KB Output is correct
4 Correct 0 ms 528 KB Output is correct
5 Correct 0 ms 520 KB Output is correct
6 Correct 1 ms 616 KB Output is correct
7 Correct 0 ms 616 KB Output is correct
8 Correct 0 ms 528 KB Output is correct
9 Correct 0 ms 528 KB Output is correct
10 Correct 0 ms 528 KB Output is correct
11 Correct 1 ms 528 KB Output is correct
12 Correct 0 ms 528 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 153 ms 12296 KB Wrong Answer [6]
2 Halted 0 ms 0 KB -