# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
434261 | jhwest2 | City (JOI17_city) | C++14 | 196 ms | 22228 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "Encoder.h"
#include <bits/stdc++.h>
#define va first
#define vb second
using namespace std;
typedef long long lint;
typedef pair<int, int> pint;
const int M = 1 << 18, N = 1 << 8;
int n, in, A[M], B[M], K[N];
vector<int> G[M];
void dfs(int p, int cur) {
lint l = ++in, r;
for (int x : G[cur]) if (p != x) {
dfs(cur, x);
}
int x = lower_bound(K, K + N, in + 1 - l) - K;
in = l + K[x] - 1;
Code(cur, (l << 8) + x);
}
void Encode(int _n, int A[], int B[]) {
n = _n;
for (int i = 0; i + 1 < n; i++) {
G[A[i]].push_back(B[i]);
G[B[i]].push_back(A[i]);
}
K[0] = 1;
for (int i = 1; i < N; i++) {
K[i] = max(K[i - 1] + 1, K[i - 1] * 21 / 20);
}
dfs(0, 0);
}
#include "Device.h"
#include <bits/stdc++.h>
#define va first
#define vb second
using namespace std;
typedef long long lint;
typedef pair<int, int> pint;
const int N = 1 << 8;
/* int K[N]; */
void InitDevice()
{
/* K[0] = 1;
for (int i = 1; i < N; i++) {
K[i] = max(K[i - 1] + 1, K[i - 1] * 21 / 20);
} */
}
int Answer(lint s, lint t)
{
lint ls = s >> 8, rs = ls + (s & N - 1);
lint lt = t >> 8, rt = lt + (t & N - 1);
if (lt <= ls && ls <= rt) return 0;
if (ls <= lt && lt <= rs) return 1;
return 2;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |