# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
417712 | 2021-06-04T07:44:10 Z | 조영욱(#7641) | Rooted MST (innopolis2021_final_E) | C++17 | 4000 ms | 23692 KB |
#include <bits/stdc++.h> using namespace std; int n,m; int arr[300001]; typedef pair<int,int> P; typedef pair<int,P> iP; int p[300001]; int find(int a) { return p[a]<0?a:p[a]=find(p[a]); } void merge(int a,int b) { a=find(a); b=find(b); if (a==b) { return; } p[b]=a; } long long mst(vector<iP> edge) { for(int i=1;i<=n;i++) { edge.push_back(iP(arr[i],P(0,i))); } sort(edge.begin(),edge.end()); for(int i=0;i<=n;i++) { p[i]=-1; } long long ret=0; for(int i=0;i<edge.size();i++) { int u=edge[i].second.first; int v=edge[i].second.second; int w=edge[i].first; if (find(u)!=find(v)) { merge(u,v); ret+=w; } } return ret; } int main(void) { vector<iP> edge; scanf("%d %d",&n,&m); for(int i=1;i<=n;i++) { scanf("%d",arr+i); } for(int i=0;i<m;i++) { int u,v,w; scanf("%d %d %d",&u,&v,&w); edge.push_back(iP(w,P(u,v))); } int q; scanf("%d",&q); for(int i=0;i<q;i++) { int ind,w; scanf("%d %d",&ind,&w); arr[ind]=w; printf("%lld\n",mst(edge)); } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Correct | 1 ms | 204 KB | Output is correct |
3 | Correct | 2 ms | 204 KB | Output is correct |
4 | Correct | 176 ms | 360 KB | Output is correct |
5 | Correct | 772 ms | 564 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 4054 ms | 16692 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 4078 ms | 10928 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 4072 ms | 12364 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 4072 ms | 12364 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 4091 ms | 23692 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Correct | 1 ms | 204 KB | Output is correct |
3 | Correct | 2 ms | 204 KB | Output is correct |
4 | Correct | 176 ms | 360 KB | Output is correct |
5 | Correct | 772 ms | 564 KB | Output is correct |
6 | Execution timed out | 4091 ms | 6344 KB | Time limit exceeded |
7 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Correct | 1 ms | 204 KB | Output is correct |
3 | Correct | 2 ms | 204 KB | Output is correct |
4 | Correct | 176 ms | 360 KB | Output is correct |
5 | Correct | 772 ms | 564 KB | Output is correct |
6 | Execution timed out | 4054 ms | 16692 KB | Time limit exceeded |
7 | Halted | 0 ms | 0 KB | - |