# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
717314 |
2023-04-01T20:18:14 Z |
vjudge1 |
Paths (RMI21_paths) |
C++17 |
|
600 ms |
22728 KB |
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define int long long
#define endl '\n'
using namespace std;
using namespace __gnu_pbds;
using ordered_set = tree<pair<int,int>,null_type,less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update>;
vector<pair<int,int>>vct[100001];
map<pair<int,int>,int>mp;
int ans,n,in=1;
void slv(){
priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>>>pq;
pq.push({0,in});
vector<int>vis(n+1);
vis[in]=in;
while(pq.size()){
int a=pq.top().second,b=pq.top().first;
pq.pop();
in=a;
for(auto &i:vct[a]){
if(!vis[i.first]){
vis[i.first]=a;
pq.push({b+mp[{a,i.first}],i.first});
}
}
}
int I=in;
while(vis[I]!=I){
ans+=mp[{vis[I],I}];
mp[{vis[I],I}]=0;
mp[{I,vis[I]}]=0;
I=vis[I];
}
}
signed main(){
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int k;
cin>>n>>k;
for(int i=1;i<n;i++){
int a,b,c;
cin>>a>>b>>c;
vct[a].push_back({b,c});
vct[b].push_back({a,c});
}
int K=k;
for(int w=1;w<=n;w++){
ans=0;
in=w;
for(int j=1;j<=n;j++){
for(auto &z:vct[j]){
mp[{j,z.first}]=z.second;
}
}
k=K;
while(k--)slv();
cout<<ans<<endl;
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
2644 KB |
Output is correct |
2 |
Correct |
2 ms |
2644 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
2644 KB |
Output is correct |
2 |
Correct |
2 ms |
2644 KB |
Output is correct |
3 |
Correct |
112 ms |
2644 KB |
Output is correct |
4 |
Correct |
109 ms |
2696 KB |
Output is correct |
5 |
Correct |
106 ms |
2700 KB |
Output is correct |
6 |
Correct |
76 ms |
2696 KB |
Output is correct |
7 |
Correct |
110 ms |
2704 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
2644 KB |
Output is correct |
2 |
Correct |
2 ms |
2644 KB |
Output is correct |
3 |
Correct |
112 ms |
2644 KB |
Output is correct |
4 |
Correct |
109 ms |
2696 KB |
Output is correct |
5 |
Correct |
106 ms |
2700 KB |
Output is correct |
6 |
Correct |
76 ms |
2696 KB |
Output is correct |
7 |
Correct |
110 ms |
2704 KB |
Output is correct |
8 |
Execution timed out |
1063 ms |
2772 KB |
Time limit exceeded |
9 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
2644 KB |
Output is correct |
2 |
Correct |
2 ms |
2644 KB |
Output is correct |
3 |
Correct |
112 ms |
2644 KB |
Output is correct |
4 |
Correct |
109 ms |
2696 KB |
Output is correct |
5 |
Correct |
106 ms |
2700 KB |
Output is correct |
6 |
Correct |
76 ms |
2696 KB |
Output is correct |
7 |
Correct |
110 ms |
2704 KB |
Output is correct |
8 |
Execution timed out |
1063 ms |
2772 KB |
Time limit exceeded |
9 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1026 ms |
22728 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
2644 KB |
Output is correct |
2 |
Correct |
2 ms |
2644 KB |
Output is correct |
3 |
Correct |
112 ms |
2644 KB |
Output is correct |
4 |
Correct |
109 ms |
2696 KB |
Output is correct |
5 |
Correct |
106 ms |
2700 KB |
Output is correct |
6 |
Correct |
76 ms |
2696 KB |
Output is correct |
7 |
Correct |
110 ms |
2704 KB |
Output is correct |
8 |
Execution timed out |
1063 ms |
2772 KB |
Time limit exceeded |
9 |
Halted |
0 ms |
0 KB |
- |