QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#672138#995. 桥sevenkiRE 0ms0kbC++23885b2024-10-24 15:48:092024-10-24 15:48:10

Judging History

你现在查看的是最新测评结果

  • [2024-10-24 15:48:10]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:0kb
  • [2024-10-24 15:48:09]
  • 提交

answer

#include <bits/stdc++.h>
#define MAXN 200005
#define fsync ios::sync_with_stdio(false);cin.tie(nullptr),cout.tie(nullptr)
using namespace std;
using ll = long long;
int n,m;
int low[MAXN],dfn[MAXN],num;
int idx[MAXN];
bool cut[MAXN];
int tot=1;
struct node{
	int u,v,nxt;
}e[MAXN];
void add(int u,int v){
	e[++tot]={u,v,idx[u]};idx[u]=tot;
	e[++tot]={v,u,idx[v]};idx[v]=tot;
}
void dfs(int x,int pre){
	low[x]=dfn[x]=++num;
	for(int i=idx[x];i;i=e[i].nxt){
		int v=e[i].v;
		if(i==pre || (i^1)==pre)continue;
		if(dfn[v])low[x]=min(low[x],dfn[v]);
		else{
			dfs(v,i);
			if(low[v]>dfn[x])cut[i]=cut[i^1]=1;
			low[x]=min(low[x],low[v]);
		}
	}
}
int main(){
	fsync;
	cin>>n>>m;
	for(int i=1;i<=m;i++){
		int x,y;cin>>x>>y;add(x,y);
	}
	for(int i=1;i<=n;i++){
		if(!dfn[i])dfs(i,0);
	}
	for(int i=1;i<=m;i++){
		if(cut[i*2]){
			cout<<e[i*2].u<<" "<<e[i*2].v<<"\n";
		}
	}
	return 0;
}

详细

Test #1:

score: 0
Runtime Error

input:

24942 387166
12556 21443
22404 16376
11073 24296
1535 11968
23745 2818
5073 12731
22550 14761
24118 12008
22695 18979
15118 13639
2080 8721
692 22578
22581 15267
9278 4127
7457 21674
17693 23448
10949 23429
9700 6009
14140 5064
7742 15164
17336 1662
18903 9760
17645 19575
6540 11942
11 4937
15282 10...

output:


result: