Submission #979158

#TimeUsernameProblemLanguageResultExecution timeMemory
979158Mher777Road Closures (APIO21_roads)C++17
0 / 100
22 ms7772 KiB
#include "roads.h" #define _CRT_SECURE_NO_WARNINGS #include <iostream> #include <iomanip> #include <array> #include <string> #include <algorithm> #include <cmath> #include <set> #include <map> #include <unordered_set> #include <unordered_map> #include <vector> #include <stack> #include <queue> #include <deque> #include <bitset> #include <list> #include <iterator> #include <numeric> #include <complex> #include <utility> #include <random> #include <cassert> #include <fstream> using namespace std; mt19937 rnd(7069); typedef int itn; typedef long long ll; typedef unsigned long long ull; typedef double db; typedef float fl; typedef long double ld; using vi = vector<int>; using vll = vector<ll>; using mii = map<int, int>; using mll = map<ll, ll>; using pii = pair<int, int>; using pll = pair<ll, ll>; #define ff first #define ss second #define pub push_back #define pob pop_back #define puf push_front #define pof pop_front #define mpr make_pair #define yes cout<<"Yes\n" #define no cout<<"No\n" #define all(x) (x).begin(), (x).end() const int dx[8] = { -1, 0, 1, 0, -1, -1, 1, 1 }; const int dy[8] = { 0, -1, 0, 1, -1, 1, -1, 1 }; const int MAX = int(2e9 + 5); const ll MAXL = ll(1e18) + 5ll; const ll MOD = ll(1000000007); const ll MOD2 = ll(998244353); const int N = 2005; vector<pair<int, ll>> g[N]; int n; vll minimum_closure_costs(int NX, vi U, vi V, vi W) { n = NX; vll ans(n); multiset<ll> mst; for (int i = 0; i < n - 1; ++i) { ++U[i]; ++V[i]; mst.insert(W[i]); ans[0] += W[i]; g[U[i]].pub({ V[i],W[i] }); g[V[i]].pub({ U[i],W[i] }); } int ind = n - 1; ll cur = 0; while (ind) { ans[ind] = cur; --ind; if (ind == -1) break; cur += *mst.begin(); mst.erase(mst.begin()); } return ans; } /* 5 0 1 1 0 2 4 0 3 3 2 4 2 4 0 1 5 2 0 10 0 3 5 */
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...