제출 #737307

#제출 시각아이디문제언어결과실행 시간메모리
737307keisuke6도로 폐쇄 (APIO21_roads)C++14
컴파일 에러
0 ms0 KiB
#include "roads.h" #include <vector> #include <algorithm> using namespace std; #typedef long long ll; std::vector<ll> minimum_closure_costs(int N, std::vector<int> U, std::vector<int> V, std::vector<int> W) { vector<ll> A = {}; ll a = 0; for(int i=0;i<W.size();i++) a += W[i]; A.push_back(a); a = 0; ll b = 0; for(int i=0;i<W.size();i++){ if(i%2) a += W[i]; else b += W[i]; } A.push_back(min(a,b)); while(A.size() != N) A.push_back(0); return A; }

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

roads.cpp:6:2: error: invalid preprocessing directive #typedef
    6 | #typedef long long ll;
      |  ^~~~~~~
roads.cpp:7:13: error: 'll' was not declared in this scope
    7 | std::vector<ll> minimum_closure_costs(int N, std::vector<int> U, std::vector<int> V, std::vector<int> W) {
      |             ^~
roads.cpp:7:15: error: template argument 1 is invalid
    7 | std::vector<ll> minimum_closure_costs(int N, std::vector<int> U, std::vector<int> V, std::vector<int> W) {
      |               ^
roads.cpp:7:15: error: template argument 2 is invalid
roads.cpp:7:17: error: ambiguating new declaration of 'int minimum_closure_costs(int, std::vector<int>, std::vector<int>, std::vector<int>)'
    7 | std::vector<ll> minimum_closure_costs(int N, std::vector<int> U, std::vector<int> V, std::vector<int> W) {
      |                 ^~~~~~~~~~~~~~~~~~~~~
In file included from roads.cpp:1:
roads.h:3:24: note: old declaration 'std::vector<long long int> minimum_closure_costs(int, std::vector<int>, std::vector<int>, std::vector<int>)'
    3 | std::vector<long long> minimum_closure_costs(int N, std::vector<int> U,
      |                        ^~~~~~~~~~~~~~~~~~~~~
roads.cpp: In function 'int minimum_closure_costs(int, std::vector<int>, std::vector<int>, std::vector<int>)':
roads.cpp:8:10: error: 'll' was not declared in this scope
    8 |   vector<ll> A = {};
      |          ^~
roads.cpp:8:12: error: template argument 1 is invalid
    8 |   vector<ll> A = {};
      |            ^
roads.cpp:8:12: error: template argument 2 is invalid
roads.cpp:9:5: error: expected ';' before 'a'
    9 |   ll a = 0;
      |     ^~
      |     ;
roads.cpp:10:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   10 |   for(int i=0;i<W.size();i++) a += W[i];
      |               ~^~~~~~~~~
roads.cpp:10:31: error: 'a' was not declared in this scope
   10 |   for(int i=0;i<W.size();i++) a += W[i];
      |                               ^
roads.cpp:11:5: error: request for member 'push_back' in 'A', which is of non-class type 'int'
   11 |   A.push_back(a);
      |     ^~~~~~~~~
roads.cpp:11:15: error: 'a' was not declared in this scope
   11 |   A.push_back(a);
      |               ^
roads.cpp:13:5: error: expected ';' before 'b'
   13 |   ll b = 0;
      |     ^~
      |     ;
roads.cpp:14:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   14 |   for(int i=0;i<W.size();i++){
      |               ~^~~~~~~~~
roads.cpp:16:10: error: 'b' was not declared in this scope
   16 |     else b += W[i];
      |          ^
roads.cpp:18:5: error: request for member 'push_back' in 'A', which is of non-class type 'int'
   18 |   A.push_back(min(a,b));
      |     ^~~~~~~~~
roads.cpp:18:21: error: 'b' was not declared in this scope
   18 |   A.push_back(min(a,b));
      |                     ^
roads.cpp:19:11: error: request for member 'size' in 'A', which is of non-class type 'int'
   19 |   while(A.size() != N) A.push_back(0);
      |           ^~~~
roads.cpp:19:26: error: request for member 'push_back' in 'A', which is of non-class type 'int'
   19 |   while(A.size() != N) A.push_back(0);
      |                          ^~~~~~~~~