QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#917188 | #995. 桥 | luobotianle# | WA | 75ms | 18396kb | C++14 | 843b | 2025-02-27 09:28:01 | 2025-02-27 09:28:02 |
Judging History
answer
#include<bits/stdc++.h>
#define int ll
using namespace std;
typedef long long ll;
const int N=1e5+5;
int n,m;
struct edge{
int next,to;
}e[N*10];
int h[N],cnt=1;
void add(int u,int v){
e[++cnt]={h[u],v};
h[u]=cnt;
}
int cut[N];
int dfn[N],low[N],tot;
void tarjan(int x,int lst){
dfn[x]=low[x]=++tot;
for(int i=h[x];i;i=e[i].next){
int to=e[i].to;
if(!dfn[to]){
tarjan(to,i);
if(dfn[x]<low[to])cut[i]=cut[i^1]=1;
low[x]=min(low[x],low[to]);
}
else if(i!=(lst^1))low[x]=min(low[x],dfn[to]);
}
}
signed main(){
ios::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
cin>>n>>m;
for(int i=1,u,v;i<=m;i++){
cin>>u>>v;
add(u,v),add(v,u);
}
for(int i=1;i<=n;i++)if(!dfn[i])tarjan(i,0);
for(int i=2;i<=cnt;i+=2){
if(cut[i])cout<<e[i^1].to<<" "<<e[i].to<<"\n";
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 75ms
memory: 18396kb
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:
1843 9897 20402 17781 13817 4945 10035 24152 19397 15941 20196 20432 1471 21188 24039 12928 8022 4041 13501 20235 23258 12570 3452 14948 19027 10296 3580 22348 21997 16263 22782 2580 23783 20250 218 11638 21724 10973 14705 11131 24048 12670 6588 16803 10791 24819 14572 14850 11719 1337 24073 16481 4...
result:
wrong output format Extra information in the output file