# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
824133 | 2023-08-13T15:10:52 Z | Moses | Road Closures (APIO21_roads) | C++14 | 630 ms | 27484 KB |
#include "roads.h" #include <bits/stdc++.h> #define F first #define S second using namespace std; const int N = 1e5+7; typedef pair<int,int> pii; vector<int> g[N]; int deg[N]; std::vector<long long> minimum_closure_costs(int N, std::vector<int> U, std::vector<int> V, std::vector<int> W) { vector<long long> ans(N,0); int n = N; for(int i = 0 ; i < n-1 ; i++) { g[U[i]].push_back(V[i]); g[V[i]].push_back(U[i]); deg[U[i]]++; deg[V[i]]++; } set<pii> st; for(int i = 0 ; i < n ; i++) st.insert({-deg[i],i}); int cnt = 0; for(int i = N-1 ; i >= 0 ; i--) { while(!st.empty() && -(*st.begin()).F > i) { auto x = *st.begin(); st.erase(st.begin()); cnt++; int u = x.S; pii mx = {-1,-1}; sort(g[u].begin(),g[u].end(),[&](int x,int y) {return deg[x] < deg[y];}); int v = g[u].back(); g[u].pop_back(); st.erase({-deg[v],v}); //cerr << u << ' ' << v << '\n'; sort(g[v].begin(),g[v].end(),[&](int x,int y) {return deg[x] < deg[y];}); g[v].pop_back(); deg[u]--; if (deg[u]) st.insert({-deg[u],u}); deg[v]--; if (deg[v]) { st.insert({-deg[v],v}); } } ans[i] = cnt; } return ans; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 2644 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 2644 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 2644 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 2644 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 630 ms | 27484 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 630 ms | 27484 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 2644 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |