제출 #1016035

#제출 시각아이디문제언어결과실행 시간메모리
1016035c2zi6통행료 (IOI18_highway)C++14
12 / 100
125 ms16976 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 gpa; VVPI gpb; VI depth; VI parind; VI par; VI euler; void dfs(int u = 0, int p = -1, int pind = -1) { if (u) euler.pb(u); parind[u] = pind; par[u] = p; for (auto[v, ind] : gpb[u]) if (ind != pind) { depth[v] = depth[u]+1; dfs(v, u, ind); } } void BFS(int r) { gpb = VVPI(n); queue<int> q; VI vis(n); q.push(r); vis[r] = true; while (q.size()) { int u = q.front(); q.pop(); for (auto[v, ind] : gpa[u]) if (!vis[v]) { gpb[u].pb({v, ind}); gpb[v].pb({u, ind}); q.push(v); vis[v] = true; } } } void find_pair(int N, std::vector<int> U, std::vector<int> V, int A, int B) { n = N; m = U.size(); gpa = VVPI(n); rep(i, m) { gpa[U[i]].pb({V[i], i}); gpa[V[i]].pb({U[i], i}); } ll base = ask(VI(m)); int d = base/A; int w; if (true) { //searching for value of w auto f = [&](int x) { VI W(m); replr(u, 0, x) for (auto[v, ind] : gpa[u]) { W[ind] = true; } return ask(W) > base; }; int l = -1, r = n-1; while (l+1 < r) { int m = (l + r) / 2; if (f(m) == 0) l = m; else r = m; } w = r; } int s; if (true) { //searching for value of s BFS(w); depth = parind = par = VI(n); euler = VI(); dfs(w); auto f = [&](int x) { VI W(m); replr(i, 0, x) W[parind[euler[i]]] = true; return (ask(W)-base)/(B-A); }; int l = -1, r = m-1; while (l+1 < r) { int m = (l + r) / 2; if (f(m) < d) l = m; else r = m; } s = euler[r]; } int t; if (true) { //searching for value of t BFS(s); depth = parind = par = VI(n); euler = VI(); dfs(s); 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; } t = b[r]; } answer(s, t); } /*ask(VI w);*/ /*answer(int s, int t)*/

컴파일 시 표준 에러 (stderr) 메시지

highway.cpp: In function 'void dfs(int, int, int)':
highway.cpp:46:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   46 |     for (auto[v, ind] : gpb[u]) if (ind != pind) {
      |              ^
highway.cpp: In function 'void BFS(int)':
highway.cpp:61:18: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   61 |         for (auto[v, ind] : gpa[u]) if (!vis[v]) {
      |                  ^
highway.cpp: In lambda function:
highway.cpp:88:37: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   88 |             replr(u, 0, x) for (auto[v, ind] : gpa[u]) {
      |                                     ^
#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...