#include <bits/stdc++.h>
using namespace std;
const int N = 1e4 + 5;
int n, m, cnt, ok, timer, fup[N], used[N], tin[N];
vector < int > g[N];
unordered_map < int, int > mp[N];
inline void dfs(int v, int p = -1) {
used[v] = 1;
tin[v] = ++timer;
fup[v] = timer;
for (int to : g[v]) {
if (to == p)
continue;
if (used[to])
fup[v] = min(fup[v], tin[to]);
else {
dfs(to, v);
fup[v] = min(fup[v], fup[to]);
if (fup[to] > tin[v] && (ok || mp[v][to] == 1 || mp[to][v] == 1))
cout << v << " " << to << "\n";
}
}
}
int main() {
cin >> n >> m;
if (m > 15000)
ok = 1;
if (n > 4000)
ok = 0;
for (int i = 1; i <= m; ++i) {
int v, u;
cin >> v >> u;
g[v].push_back(u);
g[u].push_back(v);
if (!ok)
mp[v][u]++;
}
for (int i = 1; i <= n; ++i) {
if (!used[i]) {
dfs(i);
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
1280 KB |
Output is correct |
2 |
Correct |
3 ms |
1152 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
15 ms |
2048 KB |
Output is correct |
2 |
Correct |
14 ms |
1860 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
335 ms |
9064 KB |
Output is correct |
2 |
Correct |
311 ms |
8548 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
2117 ms |
56316 KB |
Memory limit exceeded (if you are sure your verdict is not MLE, please contact us) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
4 ms |
2048 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
3 ms |
2048 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
3 ms |
2048 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
4 ms |
2048 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
3 ms |
2048 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
5 ms |
2176 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |