# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
563769 | pvpwarrior | 도로 폐쇄 (APIO21_roads) | C++14 | 2057 ms | 21192 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "roads.h"
#include <bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL)
#define ll long long
#define vi std::vector<ll>
#define si set<ll>
#define INF 100000000
#define pb push_back
#define mod 1000000007
std::vector<long long> minimum_closure_costs(int N, std::vector<int> U,
std::vector<int> V,
std::vector<int> W) {
ll n = N;
set<pair < ll, ll > > adj[n];
// for (int i = 0; i < n-1; ++i){
// cin >> u[i] >> v[i] >> w[i];
// }
// for (int i = 0; i < n; ++i){
// cin >> v[i];
// }
// for (int i = 0; i < n; ++i){
// cin >> w[i];
// }
for (int i = 0; i < n-1; ++i){
adj[V[i]].insert(make_pair(W[i] , U[i]));
adj[U[i]].insert(make_pair(W[i] , V[i]));
}
// for (int i = 0; i < n; ++i)
// {
// cout << i << ": ";
// for(auto x: adj[i]){
// cout << "(" << x.first << ", " << x.second << "), ";
// }
// cout << "\n";
// }
vi ans(n,0);
ll sum = 0;
for (int k = n-1; k >= 0; k--){
sum = 0;
// cout << k << " :\n";
for (int i = 0; i < n; ++i){
while(adj[i].size() > k){
auto it = adj[i].begin();
pair <ll ,ll > x = *it;
sum += x.first;
ll in = x.second;
auto it2 = adj[in].find(make_pair(x.first, i));
pair <ll ,ll > y = *it2;
adj[x.second].erase(it2);
// return 0;
// cout << x.first << " " << x.second << "\n";
// cout << y.first << " " << y.second << "\n";
adj[i].erase(it);
// cout << "\n";
}
// cout << "\n";
}
// cout << "\n";
if(n-1-k) ans[n-1-k]=ans[n-k-2];
ans[n-1-k] += sum;
}
// for (int i = n-1; i >= 0; i--){
// cout << ans[i] << " ";
// }
return ans;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |