Submission #1116580

#TimeUsernameProblemLanguageResultExecution timeMemory
1116580PagodePaivaRoad Closures (APIO21_roads)C++17
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> #include "roads.h" #include <vector> using namespace std; const int N = 100010; int v[N]; std::vector<long long> minimum_closure_costs(int n, std::vector<int> U, std::vector<int> V, std::vector<int> W) { long long res = 0; vector <long long> ans; int pref[n+1]; int suf[n+1]; for(int i = 0;i <= n;i++){ pref[i] = suf[i] = 0; } long long sum = 0; for(int i = 0;i < n-1;i++){ v[i+1] = W[i]; sum += v[i+1]; } pref[1] = 0; for(int i = 2;i <= n-1;i++){ pref[i] = min(pref[i-1]+v[i], pref[i-2]+v[i-1]); } res = pref[n-1]; vector <int> ans; ans.push_back(sum); ans.push_back(res); for(int i = 2;i <= n-1;i++){ ans.push_back(0); } return ans; }

Compilation message (stderr)

roads.cpp: In function 'std::vector<long long int> minimum_closure_costs(int, std::vector<int>, std::vector<int>, std::vector<int>)':
roads.cpp:29:18: error: conflicting declaration 'std::vector<int> ans'
   29 |     vector <int> ans;
      |                  ^~~
roads.cpp:13:24: note: previous declaration as 'std::vector<long long int> ans'
   13 |     vector <long long> ans;
      |                        ^~~