# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
551917 | LucaDantas | City (JOI17_city) | C++17 | 164 ms | 15280 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>
using namespace std;
constexpr int maxn = 1<<18;
vector<int> g[maxn];
long long t, in[maxn], out[maxn];
long long dfs(int u, int p) {
if(g[u].size() == 1 && u)
in[u] = ++t;
else
in[u] = maxn-1;
for(int v : g[u]) if(v != p)
in[u] = min(in[u], dfs(v, u));
if(g[u].size() > 1 || !u)
out[u] = t;
else
out[u] = 0;
return in[u];
}
void Encode(int N, int A[], int B[])
{
for(int i = 0; i < N-1; i++)
g[A[i]].push_back(B[i]), g[B[i]].push_back(A[i]);
dfs(0, -1);
for (int i = 0; i < N; ++i)
Code(i, in[i] | (out[i] << 17));
}
#include "Device.h"
#include <bits/stdc++.h>
using namespace std;
void InitDevice()
{
}
int Answer(long long S, long long T)
{
long long in[2], out[2];
for(int rep = 0; rep < 2; rep++, swap(S, T)) {
out[rep] = S >> 18;
in[rep] = S ^ (out[rep] << 18);
}
int vira = 0;
if(in[0] > in[1])
swap(in[0], in[1]), swap(out[0], out[1]), vira = 1;
/* printf("%lld %lld | %lld %lld\n", in[0], out[0], in[1], out[1]);
printf("%d\n\n", out[0] >= in[1] ? 1^vira : 2); */
return (out[0] >= in[1] ? 1^vira : 2);
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |