# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
938145 | rainboy | Flights (JOI22_flights) | C++17 | 3 ms | 1024 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 "Ali.h"
#include <string>
#include <vector>
typedef std::vector<int> vi;
typedef std::string str;
namespace {
const int N = 100000;
int ej[N][3], eo[N];
void append(int i, int j) {
ej[i][eo[i]++] = j;
}
str aa; int k, l;
void dfs(int p, int i) {
SetID(i, k++);
if (p != -1)
aa[l++] = '0';
for (int o = eo[i]; o--; ) {
int j = ej[i][o];
if (j != p)
dfs(i, j);
}
if (p != -1)
aa[l++] = '1';
}
}
void Init(int n, vi ii, vi jj) {
for (int i = 0; i < n; i++)
eo[i] = 0;
for (int h = 0; h < n - 1; h++)
append(ii[h], jj[h]), append(jj[h], ii[h]);
aa.resize((n - 1) * 2), k = l = 0;
dfs(-1, 0);
}
str SendA(str bb) {
return aa;
}
#include "Benjamin.h"
#include <string>
#include <vector>
typedef std::vector<int> vi;
typedef std::string str;
namespace {
const int N = 100000;
int dd[N], pp[N], qu[N], n, u, v;
}
str SendB(int n_, int u_, int v_) {
n = n_, u = u_, v = v_;
return "00000000001111111111";
}
int Answer(str aa) {
int cnt;
cnt = 0;
pp[0] = -1, dd[0] = 0, qu[cnt++] = 0;
for (int i = 0, k = 1; i < (n - 1) * 2; i++)
if (aa[i] == '0')
dd[k] = dd[qu[cnt - 1]] + 1, pp[k] = qu[cnt - 1], qu[cnt++] = k++;
else
cnt--;
int d = 0;
while (u != v) {
d++;
if (dd[u] > dd[v])
u = pp[u];
else
v = pp[v];
}
return d;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |