답안 #560705

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
560705 2022-05-12T00:39:51 Z jamezzz Simurgh (IOI17_simurgh) C++17
30 / 100
181 ms 3588 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]=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);
	int tot=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);
				++tot;
				if(tot>30000)assert(false);
				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;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB correct
2 Correct 0 ms 340 KB correct
3 Correct 1 ms 340 KB correct
4 Correct 0 ms 340 KB correct
5 Correct 0 ms 340 KB correct
6 Correct 0 ms 340 KB correct
7 Correct 0 ms 340 KB correct
8 Correct 0 ms 340 KB correct
9 Correct 0 ms 340 KB correct
10 Correct 0 ms 340 KB correct
11 Correct 0 ms 340 KB correct
12 Correct 0 ms 340 KB correct
13 Correct 0 ms 340 KB correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB correct
2 Correct 0 ms 340 KB correct
3 Correct 1 ms 340 KB correct
4 Correct 0 ms 340 KB correct
5 Correct 0 ms 340 KB correct
6 Correct 0 ms 340 KB correct
7 Correct 0 ms 340 KB correct
8 Correct 0 ms 340 KB correct
9 Correct 0 ms 340 KB correct
10 Correct 0 ms 340 KB correct
11 Correct 0 ms 340 KB correct
12 Correct 0 ms 340 KB correct
13 Correct 0 ms 340 KB correct
14 Correct 4 ms 400 KB correct
15 Correct 4 ms 340 KB correct
16 Correct 4 ms 340 KB correct
17 Correct 4 ms 340 KB correct
18 Correct 2 ms 340 KB correct
19 Correct 4 ms 340 KB correct
20 Correct 3 ms 384 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 340 KB correct
28 Correct 1 ms 340 KB correct
29 Correct 1 ms 340 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 340 KB correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB correct
2 Correct 0 ms 340 KB correct
3 Correct 1 ms 340 KB correct
4 Correct 0 ms 340 KB correct
5 Correct 0 ms 340 KB correct
6 Correct 0 ms 340 KB correct
7 Correct 0 ms 340 KB correct
8 Correct 0 ms 340 KB correct
9 Correct 0 ms 340 KB correct
10 Correct 0 ms 340 KB correct
11 Correct 0 ms 340 KB correct
12 Correct 0 ms 340 KB correct
13 Correct 0 ms 340 KB correct
14 Correct 4 ms 400 KB correct
15 Correct 4 ms 340 KB correct
16 Correct 4 ms 340 KB correct
17 Correct 4 ms 340 KB correct
18 Correct 2 ms 340 KB correct
19 Correct 4 ms 340 KB correct
20 Correct 3 ms 384 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 340 KB correct
28 Correct 1 ms 340 KB correct
29 Correct 1 ms 340 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 340 KB correct
34 Runtime error 181 ms 2768 KB Execution killed with signal 6
35 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB correct
2 Correct 1 ms 356 KB correct
3 Incorrect 138 ms 3588 KB WA in grader: NO
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB correct
2 Correct 0 ms 340 KB correct
3 Correct 1 ms 340 KB correct
4 Correct 0 ms 340 KB correct
5 Correct 0 ms 340 KB correct
6 Correct 0 ms 340 KB correct
7 Correct 0 ms 340 KB correct
8 Correct 0 ms 340 KB correct
9 Correct 0 ms 340 KB correct
10 Correct 0 ms 340 KB correct
11 Correct 0 ms 340 KB correct
12 Correct 0 ms 340 KB correct
13 Correct 0 ms 340 KB correct
14 Correct 4 ms 400 KB correct
15 Correct 4 ms 340 KB correct
16 Correct 4 ms 340 KB correct
17 Correct 4 ms 340 KB correct
18 Correct 2 ms 340 KB correct
19 Correct 4 ms 340 KB correct
20 Correct 3 ms 384 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 340 KB correct
28 Correct 1 ms 340 KB correct
29 Correct 1 ms 340 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 340 KB correct
34 Runtime error 181 ms 2768 KB Execution killed with signal 6
35 Halted 0 ms 0 KB -