제출 #294584

#제출 시각아이디문제언어결과실행 시간메모리
294584SeDunion통행료 (IOI18_highway)C++14
컴파일 에러
0 ms0 KiB
#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); } 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 ({}); dfs (0, dist); int l = 0, r = int(mb.size()) - 1; while (l < r) { int m = (l + r) >> 1; vector<int>now; for (int i = 0 ; i <= m ; ++ i) { now.push_back (mb[i].second); } if (Ask(now) > dist) { r = m; } else { l = m + 1; } } answer (0, mb[r].first); }

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

highway.cpp: In function 'void dfs(int, ll, int)':
highway.cpp:17:12: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   17 |  for (auto [to, i] : g[v]) if (to != p) {
      |            ^
highway.cpp: In function 'void find_pair(int, std::vector<int>, std::vector<int>, int, int)':
highway.cpp:32:19: error: cannot bind non-const lvalue reference of type 'std::vector<int>&' to an rvalue of type 'std::vector<int>'
   32 |  ll dist = Ask ({});
      |                   ^
In file included from /usr/include/c++/9/vector:67,
                 from highway.h:3,
                 from highway.cpp:1:
/usr/include/c++/9/bits/stl_vector.h:484:7: note:   after user-defined conversion: 'std::vector<_Tp, _Alloc>::vector() [with _Tp = int; _Alloc = std::allocator<int>]'
  484 |       vector() = default;
      |       ^~~~~~
highway.cpp:7:22: note:   initializing argument 1 of 'll Ask(std::vector<int>&)'
    7 | ll Ask (vector<int> &v) {
      |         ~~~~~~~~~~~~~^