Submission #263243

#TimeUsernameProblemLanguageResultExecution timeMemory
263243NicolaAbusaad2014Highway Tolls (IOI18_highway)C++14
Compilation error
0 ms0 KiB
#include "highway.h"
#include <bits/stdc++.h>
using namespace std;
long long mn;
int T;
map<long,map<long,long> >m;
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==m[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) {
  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]);
  m[V[i]][U[i]]=i;
  m[U[i]][V[i]]=i;
  }
  dfs(0,0,0);
  answer(0,T);
}

Compilation message (stderr)

highway.cpp: In function 'void dfs(long int, long int, long int)':
highway.cpp:11:24: error: 'M' was not declared in this scope
   11 |     std::vector<int> w(M);
      |                        ^
highway.cpp:19:17: error: 'A' was not declared in this scope
   19 |     if(toll>(mn*A)){
      |                 ^
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:37:13: error: no match for call to '(std::vector<long long int>) (__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type&)'
   37 |   edges(V[i]).push_back(U[i]);
      |             ^
highway.cpp:38:13: error: no match for call to '(std::vector<long long int>) (__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type&)'
   38 |   edges(U[i]).push_back(V[i]);
      |             ^