Submission #825200

#TimeUsernameProblemLanguageResultExecution timeMemory
825200t6twotwoRoad Closures (APIO21_roads)C++17
Compilation error
0 ms0 KiB
#include "roads.h" #include <bits/stdc++.h> using namespace std; using ll = long long; vector<ll> minimum_closure_costs(int N, vector<int> U, vector<int> V, vector<int> W) { vector<ll> ans(N); if (U == vector(N, 0) { sort(W.begin(), W.end()); for (int i = 0; i < N - 1; i++) { ans[N - 2 - i] = ans[N - 1 - i] + W[i]: } return ans; } ll dp0 = 0, dp1 = 0; for (int i = 0; i < N - 1; i++) { auto t = dp0; dp0 = min(dp0, dp1) + W[i]; dp1 = t; } ans[0] = accumulate(W.begin(), W.end(), 0LL); ans[1] = min(dp0, dp1); 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:7:26: error: expected ';' before '{' token
    7 |     if (U == vector(N, 0) {
      |                          ^~
      |                          ;
roads.cpp:14:15: error: expected ')' before ',' token
   14 |     ll dp0 = 0, dp1 = 0;
      |               ^
      |               )
roads.cpp:7:8: note: to match this '('
    7 |     if (U == vector(N, 0) {
      |        ^
roads.cpp:14:8: warning: unused variable 'dp0' [-Wunused-variable]
   14 |     ll dp0 = 0, dp1 = 0;
      |        ^~~
roads.cpp:16:18: error: 'dp0' was not declared in this scope
   16 |         auto t = dp0;
      |                  ^~~
roads.cpp:17:24: error: 'dp1' was not declared in this scope
   17 |         dp0 = min(dp0, dp1) + W[i];
      |                        ^~~
roads.cpp:21:18: error: 'dp0' was not declared in this scope
   21 |     ans[1] = min(dp0, dp1);
      |                  ^~~
roads.cpp:21:23: error: 'dp1' was not declared in this scope
   21 |     ans[1] = min(dp0, dp1);
      |                       ^~~