QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#662330 | #999. 边双连通分量 | Littlelu | WA | 1ms | 6216kb | C++14 | 890b | 2024-10-20 23:01:29 | 2024-10-20 23:01:29 |
Judging History
answer
// QOJ #995 - 桥
// Code by Alexandre Lea
#include <bits/stdc++.h>
using namespace std;
const int N=1e5+5;
struct edge{
int u,v;
edge(int u=0,int v=0):u(u),v(v){}
};
int n,m;
vector<edge> edges;
vector<int> gr[N],ans;
void adde(int u,int v){
edges.push_back(edge(u,v));
gr[u].push_back(edges.size()-1);
}
int dfn[N],low[N],dft;
void dfs(int u,int fa){
dfn[u]=low[u]=++dft;
for(int ei:gr[u]){
int v=edges[ei].v;
if(dfn[v]==0){
dfs(v,u),low[u]=min(low[u],low[v]);
if(dfn[u]<low[v]) ans.push_back((ei|1)^1);
}else if(v!=fa&&dfn[v]!=0) low[u]=min(low[u],dfn[v]);
}
}
int main(){
cin>>n>>m;
for(int i=1,a,b;i<=m;++i) cin>>a>>b,adde(a,b),adde(b,a);
for(int i=1;i<=n;++i) if(dfn[i]==0) dfs(i,i);
for(auto ie:ans) cout<<edges[ie].u<<" "<<edges[ie].v<<endl;
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 6216kb
input:
4 5 0 2 0 1 3 0 2 1 2 3
output:
result:
wrong output format Unexpected end of file - int32 expected