# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
423603 | Tangent | Highway Tolls (IOI18_highway) | C++17 | 157 ms | 9612 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 "highway.h"
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vii;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vii> vvii;
typedef vector<vll> vvll;
typedef vector<vpii> vvpii;
typedef vector<vpll> vvpll;
#define ffor(i, a, b) for (ll i = a; i < b; i++)
#define rep(i, n) ffor(i, 0, n)
#define forin(x, a) for (auto &x: a)
#define all(a) a.begin(), a.end()
void find_pair(int N, std::vector<int> U, std::vector<int> V, int A, int B) {
int M = U.size();
vvpii adj(N);
rep(i, M) {
adj[U[i]].emplace_back(V[i], i);
adj[V[i]].emplace_back(U[i], i);
}
vii depth(N, -1), pedge(N, -1);
depth[0] = 0;
function<void(int)> dfs;
dfs = [&](int x) {
forin(y, adj[x]) {
if (depth[y.first] == -1) {
depth[y.first] = depth[x] + 1;
pedge[y.first] = y.second;
dfs(y.first);
}
}
};
dfs(0);
int tdepth = ask(vii(M)) / A;
vii cand;
rep(i, N) {
if (depth[i] == tdepth) {
cand.emplace_back(i);
}
}
while (cand.size() > 1) {
vii query(M);
rep(i, cand.size() / 2) {
query[pedge[cand[i]]] = 1;
}
if (ask(query) > tdepth * A) {
cand.resize(cand.size() / 2);
} else {
ffor(i, cand.size() / 2, cand.size()) {
cand[i - (cand.size() / 2)] = cand[i];
}
cand.resize(cand.size() - (cand.size() / 2));
}
}
answer(0, cand[0]);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |