Submission #1013299

#TimeUsernameProblemLanguageResultExecution timeMemory
1013299c2zi6Highway Tolls (IOI18_highway)C++14
12 / 100
233 ms262144 KiB
#define _USE_MATH_DEFINES #include <bits/stdc++.h> #define ff first #define ss second #define pb push_back #define all(a) (a).begin(), (a).end() #define replr(i, a, b) for (int i = int(a); i <= int(b); ++i) #define reprl(i, a, b) for (int i = int(a); i >= int(b); --i) #define rep(i, n) for (int i = 0; i < int(n); ++i) #define mkp(a, b) make_pair(a, b) using namespace std; typedef long long ll; typedef long double ld; typedef pair<int, int> PII; typedef vector<int> VI; typedef vector<PII> VPI; typedef vector<VI> VVI; typedef vector<VVI> VVVI; typedef vector<VPI> VVPI; typedef pair<ll, ll> PLL; typedef vector<ll> VL; typedef vector<PLL> VPL; typedef vector<VL> VVL; typedef vector<VVL> VVVL; typedef vector<VPL> VVPL; template<class T> T setmax(T& a, T b) {if (a < b) return a = b; return a;} template<class T> T setmin(T& a, T b) {if (a < b) return a; return a = b;} #include <ext/pb_ds/assoc_container.hpp> using namespace __gnu_pbds; template<class T> using indset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; #include "highway.h" int n, m; VVPI gp; VI depth; VI parind; void dfs(int u = 0, int pind = -1) { parind[u] = pind; for (auto[v, ind] : gp[u]) if (ind != pind) { depth[v] = depth[u]+1; dfs(v, ind); } } void find_pair(int N, std::vector<int> U, std::vector<int> V, int A, int B) { n = N; m = U.size(); gp = VVPI(n); rep(i, m) { gp[U[i]].pb({V[i], i}); gp[V[i]].pb({U[i], i}); } depth = parind = VI(n); dfs(); ll base = ask(VI(m)); int d = base/A; VI b; rep(u, n) if (depth[u] == d) b.pb(u); auto f = [&](int x) { VI W(m); replr(i, 0, x) W[parind[b[i]]] = true; return ask(W) > base; }; int l = -1, r = b.size()-1; while (l + 1 < r) { int m = (l + r) / 2; if (f(m)) r = m; else l = m; } answer(0, b[r]); } /*ask(VI w);*/ /*answer(int s, int t)*/

Compilation message (stderr)

highway.cpp: In function 'void dfs(int, int)':
highway.cpp:41:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   41 |     for (auto[v, ind] : gp[u]) if (ind != pind) {
      |              ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...