# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
770006 |
2023-06-30T16:25:07 Z |
vjudge1 |
Paths (RMI21_paths) |
C++17 |
|
600 ms |
9892 KB |
//YOU WILL MAKE IT
#pragma GCC optimize("Ofast")
#pragma GCC target("avx2")
#include<bits/stdc++.h>
using namespace std;
const int N=2e5;
vector<pair<int,int>> tree[N];
priority_queue<long long> pq;
void dfs(int i,int p,int sum){
pq.push(sum);
for(auto w:tree[i]){
if(w.first==p) continue;
dfs(w.first,i,sum+w.second);
}
}
void solve(){
int k,n;cin>>n>>k;
int val=n;
n--;
while(n--){
int a,b,w;cin>>a>>b>>w;
tree[a].push_back({b,w});
tree[b].push_back({a,w});
}
for(int i=1;i<=val;i++){
dfs(i,-1,0);
long long ans=0;
while(!pq.empty()){
ans+=pq.top();
pq.pop();
}
cout<<ans<<endl;
}
}
int main(){
/* freopen("hopscotch.in","r",stdin);
freopen("hopscotch.out","w",stdout);*/
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(0);
int t=1;
// cin>>t;
while(t--){
solve();
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
4948 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
4948 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
4948 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
4948 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1029 ms |
9892 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
4948 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |