# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
560701 |
2022-05-12T00:24:45 Z |
jamezzz |
Simurgh (IOI17_simurgh) |
C++17 |
|
141 ms |
4388 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[505],low[505],par[505],cnt,bcnt,good[maxn*maxn];
bool in[505];
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(u!=1&&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]=true;
}
}
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;
for(int i:bcce){
e.push_back(i);
res.push_back({count_common_roads(e),i});
e.pop_back();
}
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]=true;
}
}
}
for(int x:bcc[i])in[x]=false;
}
vector<int> ans;
for(int i=0;i<m;++i){
if(good[i])ans.push_back(i);
}
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
correct |
2 |
Correct |
1 ms |
336 KB |
correct |
3 |
Correct |
1 ms |
340 KB |
correct |
4 |
Correct |
1 ms |
340 KB |
correct |
5 |
Correct |
1 ms |
340 KB |
correct |
6 |
Correct |
0 ms |
340 KB |
correct |
7 |
Correct |
1 ms |
340 KB |
correct |
8 |
Correct |
0 ms |
340 KB |
correct |
9 |
Correct |
1 ms |
336 KB |
correct |
10 |
Correct |
1 ms |
340 KB |
correct |
11 |
Correct |
1 ms |
340 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 |
336 KB |
correct |
3 |
Correct |
1 ms |
340 KB |
correct |
4 |
Correct |
1 ms |
340 KB |
correct |
5 |
Correct |
1 ms |
340 KB |
correct |
6 |
Correct |
0 ms |
340 KB |
correct |
7 |
Correct |
1 ms |
340 KB |
correct |
8 |
Correct |
0 ms |
340 KB |
correct |
9 |
Correct |
1 ms |
336 KB |
correct |
10 |
Correct |
1 ms |
340 KB |
correct |
11 |
Correct |
1 ms |
340 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 |
4 ms |
340 KB |
correct |
16 |
Correct |
4 ms |
416 KB |
correct |
17 |
Correct |
4 ms |
340 KB |
correct |
18 |
Correct |
2 ms |
332 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 |
336 KB |
correct |
24 |
Correct |
2 ms |
340 KB |
correct |
25 |
Incorrect |
1 ms |
340 KB |
WA in grader: NO |
26 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
correct |
2 |
Correct |
1 ms |
336 KB |
correct |
3 |
Correct |
1 ms |
340 KB |
correct |
4 |
Correct |
1 ms |
340 KB |
correct |
5 |
Correct |
1 ms |
340 KB |
correct |
6 |
Correct |
0 ms |
340 KB |
correct |
7 |
Correct |
1 ms |
340 KB |
correct |
8 |
Correct |
0 ms |
340 KB |
correct |
9 |
Correct |
1 ms |
336 KB |
correct |
10 |
Correct |
1 ms |
340 KB |
correct |
11 |
Correct |
1 ms |
340 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 |
4 ms |
340 KB |
correct |
16 |
Correct |
4 ms |
416 KB |
correct |
17 |
Correct |
4 ms |
340 KB |
correct |
18 |
Correct |
2 ms |
332 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 |
336 KB |
correct |
24 |
Correct |
2 ms |
340 KB |
correct |
25 |
Incorrect |
1 ms |
340 KB |
WA in grader: NO |
26 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
correct |
2 |
Correct |
1 ms |
340 KB |
correct |
3 |
Incorrect |
141 ms |
4388 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 |
336 KB |
correct |
3 |
Correct |
1 ms |
340 KB |
correct |
4 |
Correct |
1 ms |
340 KB |
correct |
5 |
Correct |
1 ms |
340 KB |
correct |
6 |
Correct |
0 ms |
340 KB |
correct |
7 |
Correct |
1 ms |
340 KB |
correct |
8 |
Correct |
0 ms |
340 KB |
correct |
9 |
Correct |
1 ms |
336 KB |
correct |
10 |
Correct |
1 ms |
340 KB |
correct |
11 |
Correct |
1 ms |
340 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 |
4 ms |
340 KB |
correct |
16 |
Correct |
4 ms |
416 KB |
correct |
17 |
Correct |
4 ms |
340 KB |
correct |
18 |
Correct |
2 ms |
332 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 |
336 KB |
correct |
24 |
Correct |
2 ms |
340 KB |
correct |
25 |
Incorrect |
1 ms |
340 KB |
WA in grader: NO |
26 |
Halted |
0 ms |
0 KB |
- |