This problem is actually a very simple cutting edge template problem, but need to deal with the re-edge of the tutor's opinion a bit troublesome things
#include <iostream> #include <stdio.h> #include <string.h> #include <algorithm> using namespace
Std
const int maxn=20005;
const int maxm=200005;
struct Edge {int to,next,id,num;//This place requires an ID (the label of the Edge) and num (whether heavy-edged) bool cut on the base of the original template;} EDGE[MAXM];
int ANS[MAXM];
int Head[maxn],tot;
int LOW[MAXN],DFN[MAXN],STACK[MAXN];
int index,top;
BOOL INSTACK[MAXN];
BOOL CUT[MAXN];
int ADD_BLOCK[MAXN];
int bridge;
int t,a,b;
Long Long n,m;
void Addedge (int u,int v,int x,int num)//I was right when I passed four values, did not process {edge[tot].to=v When I did not pass Num;
Edge[tot].next=head[u];
Edge[tot].cut=false;
Edge[tot].id=x;
Edge[tot].num=num;
head[u]=tot++;
} void Tarjan (int u,int pre) {int v,k=1;
Low[u]=dfn[u]=++index;
Stack[top++]=u;
Instack[u]=true;
int son=0,sum=0;
for (int i=head[u]; i!=-1; i=edge[i].next) {v=edge[i].to;
if (v==pre) continue;
if (!dfn[v]) {son++;
Tarjan (V,u); If(Low[u]>low[v]) low[u]=low[v];
if (low[v]>dfn[u]&&edge[i].num!=1) {bridge++;
Edge[i].cut=true;
Edge[i^1].cut=true;
ans[bridge]=edge[i].id;//here is directly the label of the Edge}} else if (Low[u]>dfn[v]) low[u]=dfn[v];
} if (U==pre) add_block[u]=son-1;
Instack[u]=false;
top--;
} void Init () {tot=0;
bridge=0;
index=0;
memset (low,0,sizeof (Low));
memset (dfn,0,sizeof (DFN));
memset (instack,0,sizeof (instack));
memset (add_block,0,sizeof (Add_block));
memset (Edge,-1,sizeof (Edge));
memset (head,-1,sizeof (head));
memset (ans,0,sizeof (ans));
} int main () {Ios::sync_with_stdio (false);
cin>>t;
while (t--) {init ();
cin>>n>>m;
for (int i=1; i<=m; i++) {cin>>a>>b;
for (int j=head[a]; j!=-1; j=edge[j].next) if (edge[j].to==b) {edge[i].num=1;
} addedge (A,b,i,edge[i].num);
Addedge (B,a,i,edge[i].num);
} for (int i=1; i<=n; i++) {Tarjan (i,i); } cout<<bridge<<endl;//the output to be processed, the first need to consider the problem of output empty line, and then need to consider the absence of a bridge, here eat a good loss, has been WA to dead sort (ans+1,an
S+BRIDGE+1);
for (int i=1,u=bridge; i<=bridge; i++) {cout<<ans[i];
if (--u) cout<< "";
} if (bridge) cout<<endl;
if (T) cout<<endl;
} return 0;
}