# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
560758 |
2022-05-12T02:16:17 Z |
jamezzz |
Simurgh (IOI17_simurgh) |
C++17 |
|
227 ms |
4036 KB |
#include "simurgh.h"
#include <bits/stdc++.h>
using namespace std;
#define maxn 505
struct unionfind{
int rnk[maxn],par[maxn];
void init(int n){
for(int i=0;i<n;++i)par[i]=i,rnk[i]=1;
}
int fp(int i){return (par[i]==i)?i:par[i]=fp(par[i]);}
void join(int x,int y){
x=fp(x),y=fp(y);
if(x==y)return;
if(rnk[x]<rnk[y])par[x]=y;
else par[y]=x;
if(rnk[x]==rnk[y])++rnk[x];
}
}ufds;
int num[maxn],low[maxn],par[maxn],cnt,bcnt,good[maxn*maxn];
bool in[maxn];
vector<pair<int,int>> AL[maxn];
vector<int> bcc[maxn];
stack<int> s;
void dfs(int u){
num[u]=low[u]=cnt++;
s.push(u);
for(auto[v,i]:AL[u]){
if(num[v]==-1){
par[v]=u;
dfs(v);
low[u]=min(low[u],low[v]);
if(low[v]>=num[u]){
while(true){
int x=s.top();s.pop();
bcc[bcnt].push_back(x);
if(x==v)break;
}
bcc[bcnt].push_back(u);
++bcnt;
}
if(low[v]>num[u]){
good[i]=1;
}
}
else if(v!=par[u]){
low[u]=min(low[u],num[v]);
}
}
}
vector<int> find_roads(int n,vector<int> u,vector<int> v){
int m=u.size();
for(int i=0;i<m;++i){
AL[u[i]].push_back({v[i],i});
AL[v[i]].push_back({u[i],i});
}
memset(num,-1,sizeof num);
dfs(0);
for(int i=0;i<bcnt;++i){
if(bcc[i].size()==1)continue;
for(int x:bcc[i]){
in[x]=true;
}
for(int x:bcc[i]){
ufds.init(n);
vector<int> e,bcce;
for(int i=0;i<m;++i){
if((u[i]==x&&in[v[i]])||(v[i]==x&&in[u[i]])){
bcce.push_back(i);
continue;
}
if(ufds.fp(u[i])==ufds.fp(v[i]))continue;
e.push_back(i);
ufds.join(u[i],v[i]);
}
vector<pair<int,int>> res;
bool have=false;
for(int i:bcce){
if(good[i]==-1)continue;
if(good[i]==1&&have)continue;
if(good[i]==1)have=true;
e.push_back(i);
res.push_back({count_common_roads(e),i});
e.pop_back();
}
if(res.size()==0)continue;
sort(res.begin(),res.end());
int last=res.back().first;
for(int i=res.size()-1;i>=0;--i){
if(res[i].first==last)good[res[i].second]=1;
else good[res[i].second]=-1;
}
}
for(int x:bcc[i])in[x]=false;
}
vector<int> ans;
for(int i=0;i<m;++i){
if(good[i]==1)ans.push_back(i);
}
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
correct |
2 |
Correct |
1 ms |
340 KB |
correct |
3 |
Correct |
1 ms |
340 KB |
correct |
4 |
Correct |
1 ms |
332 KB |
correct |
5 |
Correct |
1 ms |
336 KB |
correct |
6 |
Correct |
1 ms |
336 KB |
correct |
7 |
Correct |
1 ms |
332 KB |
correct |
8 |
Correct |
1 ms |
340 KB |
correct |
9 |
Correct |
1 ms |
332 KB |
correct |
10 |
Correct |
1 ms |
340 KB |
correct |
11 |
Correct |
1 ms |
332 KB |
correct |
12 |
Correct |
1 ms |
340 KB |
correct |
13 |
Correct |
1 ms |
340 KB |
correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
correct |
2 |
Correct |
1 ms |
340 KB |
correct |
3 |
Correct |
1 ms |
340 KB |
correct |
4 |
Correct |
1 ms |
332 KB |
correct |
5 |
Correct |
1 ms |
336 KB |
correct |
6 |
Correct |
1 ms |
336 KB |
correct |
7 |
Correct |
1 ms |
332 KB |
correct |
8 |
Correct |
1 ms |
340 KB |
correct |
9 |
Correct |
1 ms |
332 KB |
correct |
10 |
Correct |
1 ms |
340 KB |
correct |
11 |
Correct |
1 ms |
332 KB |
correct |
12 |
Correct |
1 ms |
340 KB |
correct |
13 |
Correct |
1 ms |
340 KB |
correct |
14 |
Correct |
3 ms |
340 KB |
correct |
15 |
Correct |
3 ms |
340 KB |
correct |
16 |
Correct |
3 ms |
336 KB |
correct |
17 |
Correct |
2 ms |
340 KB |
correct |
18 |
Correct |
2 ms |
336 KB |
correct |
19 |
Correct |
3 ms |
340 KB |
correct |
20 |
Correct |
3 ms |
340 KB |
correct |
21 |
Correct |
3 ms |
340 KB |
correct |
22 |
Correct |
2 ms |
340 KB |
correct |
23 |
Correct |
2 ms |
340 KB |
correct |
24 |
Correct |
2 ms |
340 KB |
correct |
25 |
Correct |
1 ms |
340 KB |
correct |
26 |
Correct |
2 ms |
340 KB |
correct |
27 |
Correct |
2 ms |
336 KB |
correct |
28 |
Correct |
1 ms |
340 KB |
correct |
29 |
Correct |
1 ms |
336 KB |
correct |
30 |
Correct |
2 ms |
340 KB |
correct |
31 |
Correct |
2 ms |
340 KB |
correct |
32 |
Correct |
2 ms |
340 KB |
correct |
33 |
Correct |
2 ms |
336 KB |
correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
correct |
2 |
Correct |
1 ms |
340 KB |
correct |
3 |
Correct |
1 ms |
340 KB |
correct |
4 |
Correct |
1 ms |
332 KB |
correct |
5 |
Correct |
1 ms |
336 KB |
correct |
6 |
Correct |
1 ms |
336 KB |
correct |
7 |
Correct |
1 ms |
332 KB |
correct |
8 |
Correct |
1 ms |
340 KB |
correct |
9 |
Correct |
1 ms |
332 KB |
correct |
10 |
Correct |
1 ms |
340 KB |
correct |
11 |
Correct |
1 ms |
332 KB |
correct |
12 |
Correct |
1 ms |
340 KB |
correct |
13 |
Correct |
1 ms |
340 KB |
correct |
14 |
Correct |
3 ms |
340 KB |
correct |
15 |
Correct |
3 ms |
340 KB |
correct |
16 |
Correct |
3 ms |
336 KB |
correct |
17 |
Correct |
2 ms |
340 KB |
correct |
18 |
Correct |
2 ms |
336 KB |
correct |
19 |
Correct |
3 ms |
340 KB |
correct |
20 |
Correct |
3 ms |
340 KB |
correct |
21 |
Correct |
3 ms |
340 KB |
correct |
22 |
Correct |
2 ms |
340 KB |
correct |
23 |
Correct |
2 ms |
340 KB |
correct |
24 |
Correct |
2 ms |
340 KB |
correct |
25 |
Correct |
1 ms |
340 KB |
correct |
26 |
Correct |
2 ms |
340 KB |
correct |
27 |
Correct |
2 ms |
336 KB |
correct |
28 |
Correct |
1 ms |
340 KB |
correct |
29 |
Correct |
1 ms |
336 KB |
correct |
30 |
Correct |
2 ms |
340 KB |
correct |
31 |
Correct |
2 ms |
340 KB |
correct |
32 |
Correct |
2 ms |
340 KB |
correct |
33 |
Correct |
2 ms |
336 KB |
correct |
34 |
Correct |
226 ms |
1692 KB |
correct |
35 |
Correct |
219 ms |
1656 KB |
correct |
36 |
Correct |
161 ms |
1424 KB |
correct |
37 |
Correct |
12 ms |
340 KB |
correct |
38 |
Correct |
208 ms |
1688 KB |
correct |
39 |
Correct |
195 ms |
1584 KB |
correct |
40 |
Correct |
158 ms |
1432 KB |
correct |
41 |
Correct |
223 ms |
1680 KB |
correct |
42 |
Correct |
227 ms |
1672 KB |
correct |
43 |
Correct |
132 ms |
1220 KB |
correct |
44 |
Correct |
103 ms |
900 KB |
correct |
45 |
Correct |
109 ms |
980 KB |
correct |
46 |
Correct |
83 ms |
884 KB |
correct |
47 |
Correct |
38 ms |
624 KB |
correct |
48 |
Correct |
7 ms |
340 KB |
correct |
49 |
Correct |
13 ms |
340 KB |
correct |
50 |
Correct |
32 ms |
596 KB |
correct |
51 |
Correct |
123 ms |
980 KB |
correct |
52 |
Correct |
89 ms |
940 KB |
correct |
53 |
Correct |
89 ms |
876 KB |
correct |
54 |
Correct |
103 ms |
1212 KB |
correct |
55 |
Correct |
106 ms |
1040 KB |
correct |
56 |
Correct |
104 ms |
1024 KB |
correct |
57 |
Correct |
106 ms |
1028 KB |
correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
correct |
2 |
Correct |
1 ms |
340 KB |
correct |
3 |
Incorrect |
155 ms |
4036 KB |
WA in grader: NO |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
correct |
2 |
Correct |
1 ms |
340 KB |
correct |
3 |
Correct |
1 ms |
340 KB |
correct |
4 |
Correct |
1 ms |
332 KB |
correct |
5 |
Correct |
1 ms |
336 KB |
correct |
6 |
Correct |
1 ms |
336 KB |
correct |
7 |
Correct |
1 ms |
332 KB |
correct |
8 |
Correct |
1 ms |
340 KB |
correct |
9 |
Correct |
1 ms |
332 KB |
correct |
10 |
Correct |
1 ms |
340 KB |
correct |
11 |
Correct |
1 ms |
332 KB |
correct |
12 |
Correct |
1 ms |
340 KB |
correct |
13 |
Correct |
1 ms |
340 KB |
correct |
14 |
Correct |
3 ms |
340 KB |
correct |
15 |
Correct |
3 ms |
340 KB |
correct |
16 |
Correct |
3 ms |
336 KB |
correct |
17 |
Correct |
2 ms |
340 KB |
correct |
18 |
Correct |
2 ms |
336 KB |
correct |
19 |
Correct |
3 ms |
340 KB |
correct |
20 |
Correct |
3 ms |
340 KB |
correct |
21 |
Correct |
3 ms |
340 KB |
correct |
22 |
Correct |
2 ms |
340 KB |
correct |
23 |
Correct |
2 ms |
340 KB |
correct |
24 |
Correct |
2 ms |
340 KB |
correct |
25 |
Correct |
1 ms |
340 KB |
correct |
26 |
Correct |
2 ms |
340 KB |
correct |
27 |
Correct |
2 ms |
336 KB |
correct |
28 |
Correct |
1 ms |
340 KB |
correct |
29 |
Correct |
1 ms |
336 KB |
correct |
30 |
Correct |
2 ms |
340 KB |
correct |
31 |
Correct |
2 ms |
340 KB |
correct |
32 |
Correct |
2 ms |
340 KB |
correct |
33 |
Correct |
2 ms |
336 KB |
correct |
34 |
Correct |
226 ms |
1692 KB |
correct |
35 |
Correct |
219 ms |
1656 KB |
correct |
36 |
Correct |
161 ms |
1424 KB |
correct |
37 |
Correct |
12 ms |
340 KB |
correct |
38 |
Correct |
208 ms |
1688 KB |
correct |
39 |
Correct |
195 ms |
1584 KB |
correct |
40 |
Correct |
158 ms |
1432 KB |
correct |
41 |
Correct |
223 ms |
1680 KB |
correct |
42 |
Correct |
227 ms |
1672 KB |
correct |
43 |
Correct |
132 ms |
1220 KB |
correct |
44 |
Correct |
103 ms |
900 KB |
correct |
45 |
Correct |
109 ms |
980 KB |
correct |
46 |
Correct |
83 ms |
884 KB |
correct |
47 |
Correct |
38 ms |
624 KB |
correct |
48 |
Correct |
7 ms |
340 KB |
correct |
49 |
Correct |
13 ms |
340 KB |
correct |
50 |
Correct |
32 ms |
596 KB |
correct |
51 |
Correct |
123 ms |
980 KB |
correct |
52 |
Correct |
89 ms |
940 KB |
correct |
53 |
Correct |
89 ms |
876 KB |
correct |
54 |
Correct |
103 ms |
1212 KB |
correct |
55 |
Correct |
106 ms |
1040 KB |
correct |
56 |
Correct |
104 ms |
1024 KB |
correct |
57 |
Correct |
106 ms |
1028 KB |
correct |
58 |
Correct |
1 ms |
340 KB |
correct |
59 |
Correct |
1 ms |
340 KB |
correct |
60 |
Incorrect |
155 ms |
4036 KB |
WA in grader: NO |
61 |
Halted |
0 ms |
0 KB |
- |