RT。
放代码:
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <string>
#include <cstring>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#define N 10010
# define forr(b, e, x) for(int i = b; i <= e; i += x)
inline int read()
{
int ans = 0;
char ch = getchar();
while (!isdigit(ch) && ch != '-') ch = getchar();
bool sign = false;
if (ch == '-') sign = true, ch = getchar();
while (ch >= '0' && ch <= '9') ans = ans * 10 + (ch - '0'), ch = getchar();
return (sign == true ? -ans : ans);
}
typedef long long ll;
using namespace std;
int mp[200][200];
int dfn[N], low[N], n, m, id, cnt, f[N];
struct edge { int t, u; }g[N];
bool cmp(edge a, edge b)
{
if (a.t != b.t) return a.u < b.u;
return a.t < b.t;
}
inline void add(int x, int y)
{
g[++ cnt].t = x;
g[cnt].u = y;
}
void tarjian(int u)
{
int c = 0, y;
dfn[u] = low[u] = ++id;
forr (1, n, 1)
{
if (!mp[u][i]) continue;
y = i;
if (dfn[y] && y != f[u]) low[u] = min(low[u], low[y]);
if (!dfn[y])
{
f[y] = u;
tarjian(y);
low[u] = min(low[u], low[y]);
if (low[y] > dfn[u]) add(u, y);
}
}
}
int main()
{
int x, y;
n = read(), m = read();
forr (1, n, 1)
{
x = read(), y = read();
mp[x][y] = mp[y][x] = 1;
}
forr (1, n, 1)
if (!dfn[i])
tarjian(i);
sort (g + 1, g + cnt + 1, cmp);
forr (1, cnt, 1)
printf("%d %d\n", min(g[i].t, g[i].u), max(g[i].t, g[i].u));
return 0;
}