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;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// find_by_order(), order_of_key()
typedef long long ll;
typedef long double dd;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<dd, dd> pdd;
typedef vector<int> vii;
typedef vector<ll> vll;
typedef vector<dd> vdd;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<pdd> vpdd;
typedef vector<vii> vvii;
typedef vector<vll> vvll;
typedef vector<vdd> vvdd;
typedef vector<vpii> vvpii;
typedef vector<vpll> vvpll;
typedef vector<vpdd> vvpdd;
typedef vector<bool> vb;
const int inf = 1 << 30;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define ffor(i, a, b) for(ll i = a; i < b; i++)
#define forin(x, a) for (auto &x: a)
#define all(x) x.begin(), x.end()
#ifdef TEST
#define dbg(x) cout << #x << ": " << x << '\n';
#define dbgc(x) cout << #x << ":"; forin(a, x) { cout << " " << a; } cout << endl;
#define tassert(x) assert(x);
#else
#define dbg(x)
#define dbgc(x)
#define tassert(x)
#endif
void find_pair(int N, std::vector<int> U, std::vector<int> V, int A, int B) {
int M = U.size();
if (M == N - 1) {
vvpii adj(N);
rep(i, M) {
adj[U[i]].emplace_back(V[i], i);
adj[V[i]].emplace_back(U[i], i);
}
vpii parent(N, {-1, -1});
parent[0] = {-2, -2};
vii depth(N, -1);
depth[0] = 0;
deque<int> q = {0};
while (!q.empty()) {
int u = q.front();
q.pop_front();
forin(p, adj[u]) {
if (parent[p.first].first == -1) {
parent[p.first] = {u, p.second};
depth[p.first] = depth[u] + 1;
q.emplace_back(p.first);
}
}
}
ll dist = ask(vii(M, 0)) / A;
vii candidates;
rep(i, N) {
if (depth[i] == dist) {
candidates.emplace_back(i);
}
}
while (candidates.size() > 1) {
vii a, b, query(M);
rep(i, candidates.size()) {
if (i & 1) {
a.emplace_back(candidates[i]);
query[parent[candidates[i]].second] = 1;
} else {
b.emplace_back(candidates[i]);
}
}
if (ask(query) > dist * A) {
candidates = move(a);
} else {
candidates = move(b);
}
}
answer(0, candidates[0]);
}
}
Compilation message (stderr)
highway.cpp: In function 'void find_pair(int, std::vector<int>, std::vector<int>, int, int)':
highway.cpp:33:36: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
33 | #define rep(i, n) for (ll i = 0; i < n; i++)
......
83 | rep(i, candidates.size()) {
| ~~~~~~~~~~~~~~~~~~~~
highway.cpp:83:7: note: in expansion of macro 'rep'
83 | rep(i, candidates.size()) {
| ^~~
# | 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... |