제출 #255264

#제출 시각아이디문제언어결과실행 시간메모리
255264Erkhemkhuu통행료 (IOI18_highway)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #include <highway.h> using namespace std; #define ll long long #define pb push_back #define mp make_pair #define F first #define S second const int N = 100005; pair <int, int> par[N]; vector <bool> w; vector <vector <pair <int, int> > > adj(N); int flat[N], timer; void dfs(ll v, ll p) { flat[timer++] = v; for(auto &u: adj[v]) { if(u.F == p) continue; par[u.F] = {v, u.S}; dfs(u.F, v); } return; } void find_pair(int n, vector <int> u, vector <int> v, int a, int b) { int i, m, max_cost, l, r, mid, s, t; m = u.size(); for(i = 0; i < m; i++) { adj[u[i]].pb({v[i], i}); adj[v[i]].pb({u[i], i}); w[i] = true; } dfs(0, -1); max_cost = ask(w); w.resize(m, false); l = 0; r = m; while(l + 1 < r) { mid = (l + r) / 2; for(i = l; i <= mid; i++) w[par[flat[i]].S] = true; if(ask(w) >= max_cost) { r = mid; for(i = l; i <= mid; i++) w[par[flat[i]].S] = false; } else l = mid; } s = flat[l]; w.resize(m, false); dfs(s, -1); l = 1; r = m; while(l + 1 < r) { mid = (l + r) / 2; for(i = l; i <= mid; i++) w[par[flat[i]].S] = true; if(ask(w) >= max_cost) { r = mid; for(i = l; i <= mid; i++) w[par[flat[i]].S] = false; } else l = mid; } t = flat[l]; answer(s, t); return; }

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

highway.cpp: In function 'void find_pair(int, std::vector<int>, std::vector<int>, int, int)':
highway.cpp:32:21: error: invalid initialization of reference of type 'const std::vector<int>&' from expression of type 'std::vector<bool>'
     max_cost = ask(w);
                     ^
In file included from highway.cpp:2:0:
highway.h:7:11: note: in passing argument 1 of 'long long int ask(const std::vector<int>&)'
 long long ask(const std::vector<int> &w);
           ^~~
highway.cpp:39:17: error: invalid initialization of reference of type 'const std::vector<int>&' from expression of type 'std::vector<bool>'
         if(ask(w) >= max_cost) {
                 ^
In file included from highway.cpp:2:0:
highway.h:7:11: note: in passing argument 1 of 'long long int ask(const std::vector<int>&)'
 long long ask(const std::vector<int> &w);
           ^~~
highway.cpp:54:17: error: invalid initialization of reference of type 'const std::vector<int>&' from expression of type 'std::vector<bool>'
         if(ask(w) >= max_cost) {
                 ^
In file included from highway.cpp:2:0:
highway.h:7:11: note: in passing argument 1 of 'long long int ask(const std::vector<int>&)'
 long long ask(const std::vector<int> &w);
           ^~~