이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "highway.h"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int M;
ll Ask (vector<int> v) {
vector<int> w(M);
for (int i : v) w[i] = 1;
return ask (w);
}
ll pAsk (vector<pair<int,int>> v) {
vector<int> w(M);
for (auto i : v) w[i.second] = 1;
return ask (w);
}
ll rAsk (vector<int> v) {
vector<int> w(M, 1);
for (int i : v) w[i] = 0;
return ask (w);
}
const int N = 2e5;
vector<pair<int,int>> g[N], mb;
void dfs (int v, ll d, int p = -1) {
for (auto [to, i] : g[v]) if (to != p) {
if (d == 1) {
mb.push_back ({to, i});
} else {
dfs (to, d-1, v);
}
}
}
void find_pair(int N, vector<int> U, vector<int> V, int A, int B) {
M = U.size();
for (int i = 0 ; i < M ; ++ i) {
g[U[i]].push_back ({V[i], i});
g[V[i]].push_back ({U[i], i});
}
ll dist = Ask ({}) / A;
dfs (0, dist);
if (mb.empty()) while(1);
if (pAsk(mb) <= dist) while(1);
int l = 0, r = int(mb.size()) - 1;
while (l < r) {
int m = (l + r) >> 1;
vector<int>now;
for (int i = l ; i <= m ; ++ i) {
now.push_back (mb[i].second);
}
if (Ask(now) > dist) {
assert (rAsk(now) == dist);
r = m;
} else {
assert (rAsk(now) > dist);
l = m + 1;
}
}
answer (0, mb[r].first);
}
컴파일 시 표준 에러 (stderr) 메시지
highway.cpp: In function 'void dfs(int, ll, int)':
highway.cpp:27:12: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
27 | for (auto [to, i] : g[v]) if (to != p) {
| ^| # | 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... |