Submission #981355

#TimeUsernameProblemLanguageResultExecution timeMemory
981355Jawad_Akbar_JJRoad Closures (APIO21_roads)C++17
Compilation error
0 ms0 KiB
#include <iostream> #include <vector> #include <algorithm> #include "roads.h" using namespace std; #define ll long long const int N = 1e5 + 10; vector<pair<int,int>> nei[N]; vector<ll> sub1(int n,vector<int> W){ sort(rbegin(W),rend(W)); vector<ll> v; v.push_back(0); for (int i : W) v[0] += i; for (int i : W) v.push_back(v.back() - i); return v; } vector<ll> sub2(int n,vector<int> W){ ll t = W[0]; ll nt = 0; vector<ll> v(n,0); v[0] += W[0]; for (int i=1;i<n-1;i++){ ll a = t; t = min(t,nt) + W[i]; nt = a; v[0] += W[i]; } v[1] = min(t,nt); return v; } int minimum_closure_costs(int n,vector<int> U,vector<int> V,vector<int> W){ long long sum = 0,sum2 = 0,sum3 = 0; for (int i=0;i<n-1;i++) sum += U[i],sum2 += W[i],sum3 += (U[i] == i); if (sum == 0) return sub1(n,W); // if (sum2 == n-1) // return sub5(n,U,V); if (sum3 == n-1) return sub2(n,W); }

Compilation message (stderr)

roads.cpp:37:5: error: ambiguating new declaration of 'int minimum_closure_costs(int, std::vector<int>, std::vector<int>, std::vector<int>)'
   37 | int minimum_closure_costs(int n,vector<int> U,vector<int> V,vector<int> W){
      |     ^~~~~~~~~~~~~~~~~~~~~
In file included from roads.cpp:4:
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:44:14: error: cannot convert 'std::vector<long long int>' to 'int' in return
   44 |   return sub1(n,W);
      |          ~~~~^~~~~
      |              |
      |              std::vector<long long int>
roads.cpp:49:14: error: cannot convert 'std::vector<long long int>' to 'int' in return
   49 |   return sub2(n,W);
      |          ~~~~^~~~~
      |              |
      |              std::vector<long long int>