제출 #263246

#제출 시각아이디문제언어결과실행 시간메모리
263246NicolaAbusaad2014통행료 (IOI18_highway)C++14
컴파일 에러
0 ms0 KiB
#include "highway.h"
#include <bits/stdc++.h>
using namespace std;
long long mn,a,m;
int T;
map<long,map<long,long> >mp;
vector<long long>edges;
void dfs(long n,long p,long d)
{
    if(d==mn){
    std::vector<int> w(m);
    for (int i = 0; i < m; ++i) {
      w[i] = 0;
      if(i==mp[n][p]){
      w[i]=1;
      }
    }
    long long toll = ask(w);
    if(toll>(mn*a)){
    T=n;
    }
    return;
    }
    for(long i=0;i<(long)edges(n).size();i++){
    dfs(edges[n][i],n,d+1);
    }
}
void find_pair(int N, std::vector<int> U, std::vector<int> V, int A, int B) {
  a=A;
  m=M;
  int M = U.size();
  vector<int> w(M);
  for (int i = 0; i < M; ++i) {
      w[i] = 0;
    }
    mn=(ask(w)/A);
  edges.resize(N);
  for(long i=0;i<M;i++){
  edges(V[i]).push_back(U[i]);
  edges(U[i]).push_back(V[i]);
  mp[V[i]][U[i]]=i;
  mp[U[i]][V[i]]=i;
  }
  dfs(0,0,0);
  answer(0,T);
}

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

highway.cpp: In function 'void dfs(long int, long int, long int)':
highway.cpp:24:33: error: no match for call to '(std::vector<long long int>) (long int&)'
   24 |     for(long i=0;i<(long)edges(n).size();i++){
      |                                 ^
highway.cpp:25:19: error: invalid types '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type {aka long long int}[long int]' for array subscript
   25 |     dfs(edges[n][i],n,d+1);
      |                   ^
highway.cpp: In function 'void find_pair(int, std::vector<int>, std::vector<int>, int, int)':
highway.cpp:30:5: error: 'M' was not declared in this scope
   30 |   m=M;
      |     ^
highway.cpp:39:13: error: no match for call to '(std::vector<long long int>) (__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type&)'
   39 |   edges(V[i]).push_back(U[i]);
      |             ^
highway.cpp:40:13: error: no match for call to '(std::vector<long long int>) (__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type&)'
   40 |   edges(U[i]).push_back(V[i]);
      |             ^