제출 #1198462

#제출 시각아이디문제언어결과실행 시간메모리
1198462ozner77통행료 (IOI18_highway)C++20
컴파일 에러
0 ms0 KiB
#include "highway.h" #include <bits/stdc++.h> using namespace std; #define ll long long vector<vector<ll>> adj; map<ll,map<ll,ll>> M; vector<ll> depth,parent; vector<vector<ll>> prof; vector<int> w; ll n; void dfs(ll cur, ll prev) { prof[depth[cur]].push_back(cur); parent[cur]=prev; for (ll v:adj[cur]) { if (v!=prev){ depth[v]=depth[cur]+1; dfs(v, cur); } } } /*int ask(int w[]){ return 1; } void answer(ll x,ll y){ cout<<x; }*/ ll chance(ll cur){ ll l,r,m; l=0; vector<ll> hijos; for (auto x:adj[cur]) { if (x!= parent[cur]) { hijos.push_back(x); } } r=hijos.size(); while(l<r){ m=(l+r)/2; for(ll i=0;i<=m;i++){ w[M[cur][hijos[i]]]=0; } for(ll i=m+1;i<hijos.size();i++){ w[M[cur][hijos[i]]]=1; } int fabian[n]; for(ll i=0;i<n;i++){ fabian[i]=w[i]; } ll ans1=ask(fabian); for(ll i=0;i<=m;i++){ w[M[cur][hijos[i]]]=1; } for(ll i=m+1;i<hijos.size();i++){ w[M[cur][hijos[i]]]=0; } int byron[n]; for(ll i=0;i<n;i++){ byron[i]=w[i]; } ll ans2=ask(byron); if(ans1==ans2){ return -1; }else if(ans1<ans2){ l=m+1; }else{ r=m; } } return hijos[l]; } void find_pair(int N, int U[], int V[], int A, int B){ adj.resize(N); prof.resize(N); depth.resize(N); w.resize(N); n=N; for(ll i=0;i<N;i++){ w[i]=0; } for(int i=0;i<N-1;i++){ adj[U[i]].push_back(V[i]); adj[V[i]].push_back(U[i]); M[U[i]][V[i]]=i; M[V[i]][U[i]]=i; } int caca[n]; for(ll i=0;i<n;i++){ caca[i]=w[i]; } ll xd=ask(caca); ll a=xd/A; depth[0]=0; dfs(0, -1); ll b=a-1; for(auto x:prof[b]){ ll ans=chance(x); if(ans!=-1){ answer(0,ans); } } }

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

highway.cpp: In function 'long long int chance(long long int)':
highway.cpp:49:21: error: invalid initialization of reference of type 'const std::vector<int>&' from expression of type 'int [n]'
   49 |         ll ans1=ask(fabian);
      |                     ^~~~~~
In file included from highway.cpp:1:
highway.h:7:39: note: in passing argument 1 of 'long long int ask(const std::vector<int>&)'
    7 | long long ask(const std::vector<int> &w);
      |               ~~~~~~~~~~~~~~~~~~~~~~~~^
highway.cpp:60:21: error: invalid initialization of reference of type 'const std::vector<int>&' from expression of type 'int [n]'
   60 |         ll ans2=ask(byron);
      |                     ^~~~~
In file included from highway.cpp:1:
highway.h:7:39: note: in passing argument 1 of 'long long int ask(const std::vector<int>&)'
    7 | long long ask(const std::vector<int> &w);
      |               ~~~~~~~~~~~~~~~~~~~~~~~~^
highway.cpp: In function 'void find_pair(int, int*, int*, int, int)':
highway.cpp:90:15: error: invalid initialization of reference of type 'const std::vector<int>&' from expression of type 'int [n]'
   90 |     ll xd=ask(caca);
      |               ^~~~
In file included from highway.cpp:1:
highway.h:7:39: note: in passing argument 1 of 'long long int ask(const std::vector<int>&)'
    7 | long long ask(const std::vector<int> &w);
      |               ~~~~~~~~~~~~~~~~~~~~~~~~^