# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
827105 | 2023-08-16T08:46:34 Z | vnm06 | Simurgh (IOI17_simurgh) | C++14 | 1026 ms | 1972 KB |
#include<bits/stdc++.h> #include "simurgh.h" using namespace std; int sg=0; int par[500], db[500]; bool prov[500000]; int ans[500000]; vector<int> added_edges; std::vector<int> find_roads(int n, std::vector<int> u, std::vector<int> v) { int m=u.size(); for(int i=0; i<n; i++) { ///for(int j=0; j<sg; j++) //cout<<added_edges[j]<<" "; //cout<<endl; if(added_edges.size()==n-1) return added_edges; for(int i=0; i<n; i++) { par[i]=i; db[i]=1; } for(int j=0; j<sg; j++) { int v1=u[added_edges[j]], v2=v[added_edges[j]]; while(v1!=par[v1]) v1=par[v1]; while(v2!=par[v2]) v2=par[v2]; if(db[v1]>db[v2]) par[v2]=v1; else if(db[v1]>db[v2]) par[v1]=v2; else { par[v2]=v1; db[v1]++; } } ///for(int i=0; i<n; i++) //cout<<par[i]<<endl; int cmp; for(cmp=0;; cmp++) { if(par[cmp]!=cmp) continue; for(int i=0; i<n; i++) { par[i]=i; db[i]=1; } for(int j=0; j<sg; j++) { int v1=u[added_edges[j]], v2=v[added_edges[j]]; while(v1!=par[v1]) v1=par[v1]; while(v2!=par[v2]) v2=par[v2]; if(db[v1]>db[v2]) par[v2]=v1; else if(db[v1]>db[v2]) par[v1]=v2; else { par[v2]=v1; db[v1]++; } } for(int j=0; j<m; j++) { int v1=u[j], v2=v[j]; while(v1!=par[v1]) v1=par[v1]; while(v2!=par[v2]) v2=par[v2]; if(v1==v2 || v1==cmp || v2==cmp) continue; added_edges.push_back(j); if(db[v1]>db[v2]) par[v2]=v1; else if(db[v1]>db[v2]) par[v1]=v2; else { par[v2]=v1; db[v1]++; } } if(added_edges.size()==n-2) break; added_edges.resize(sg); } int mist=1e9, mast=-1; for(int j=0; j<m; j++) ans[j]=-1; for(int j=0; j<m; j++) { if(prov[j]) continue; int v1=u[j], v2=v[j]; while(v1!=par[v1]) v1=par[v1]; while(v2!=par[v2]) v2=par[v2]; if(v1!=cmp && v2!=cmp) continue; if(v1==v2) continue; prov[j]=1; added_edges.push_back(j); ans[j]=count_common_roads(added_edges); if(ans[j]>mast) mast=ans[j]; if(ans[j]<mist) mist=ans[j]; added_edges.resize(added_edges.size()-1); } added_edges.resize(sg); for(int j=0; j<m; j++) { if(ans[j]==mast) { added_edges.push_back(j); sg++; } } } return added_edges; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | correct |
2 | Correct | 0 ms | 212 KB | correct |
3 | Correct | 0 ms | 212 KB | correct |
4 | Correct | 0 ms | 212 KB | correct |
5 | Correct | 0 ms | 212 KB | correct |
6 | Correct | 0 ms | 212 KB | correct |
7 | Correct | 0 ms | 212 KB | correct |
8 | Correct | 0 ms | 212 KB | correct |
9 | Correct | 0 ms | 212 KB | correct |
10 | Correct | 0 ms | 212 KB | correct |
11 | Runtime error | 1 ms | 400 KB | Execution killed with signal 11 |
12 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | correct |
2 | Correct | 0 ms | 212 KB | correct |
3 | Correct | 0 ms | 212 KB | correct |
4 | Correct | 0 ms | 212 KB | correct |
5 | Correct | 0 ms | 212 KB | correct |
6 | Correct | 0 ms | 212 KB | correct |
7 | Correct | 0 ms | 212 KB | correct |
8 | Correct | 0 ms | 212 KB | correct |
9 | Correct | 0 ms | 212 KB | correct |
10 | Correct | 0 ms | 212 KB | correct |
11 | Runtime error | 1 ms | 400 KB | Execution killed with signal 11 |
12 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | correct |
2 | Correct | 0 ms | 212 KB | correct |
3 | Correct | 0 ms | 212 KB | correct |
4 | Correct | 0 ms | 212 KB | correct |
5 | Correct | 0 ms | 212 KB | correct |
6 | Correct | 0 ms | 212 KB | correct |
7 | Correct | 0 ms | 212 KB | correct |
8 | Correct | 0 ms | 212 KB | correct |
9 | Correct | 0 ms | 212 KB | correct |
10 | Correct | 0 ms | 212 KB | correct |
11 | Runtime error | 1 ms | 400 KB | Execution killed with signal 11 |
12 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | correct |
2 | Correct | 0 ms | 212 KB | correct |
3 | Incorrect | 1026 ms | 1972 KB | WA in grader: NO |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | correct |
2 | Correct | 0 ms | 212 KB | correct |
3 | Correct | 0 ms | 212 KB | correct |
4 | Correct | 0 ms | 212 KB | correct |
5 | Correct | 0 ms | 212 KB | correct |
6 | Correct | 0 ms | 212 KB | correct |
7 | Correct | 0 ms | 212 KB | correct |
8 | Correct | 0 ms | 212 KB | correct |
9 | Correct | 0 ms | 212 KB | correct |
10 | Correct | 0 ms | 212 KB | correct |
11 | Runtime error | 1 ms | 400 KB | Execution killed with signal 11 |
12 | Halted | 0 ms | 0 KB | - |