제출 #1116580

#제출 시각아이디문제언어결과실행 시간메모리
1116580PagodePaiva도로 폐쇄 (APIO21_roads)C++17
컴파일 에러
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; }

컴파일 시 표준 에러 (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;
      |                        ^~~