이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
int N,M, depth[100005], low[100005], p[100005];
vector< pair<int,int> > lst[100005];
bitset<100005> visited;
void dfs (int u, int d) {
visited[u] = 1, depth[u] = d, low[u] = d;
int num = 0;
for (auto v: lst[u]) {
if (!visited[v.first]) {
p[v.first] = v.second, num++;
dfs(v.first,d+1);
if (low[v.first] > depth[u]) cout << u+1 << ' ' << v.first+1 << '\n';
low[u] = min(low[u],low[v.first]);
}
else if (v.second != p[u])
low[u] = min(low[u],depth[v.first]);
}
}
int main() {
ios_base::sync_with_stdio(false); cin.tie(NULL);
cin >> N >> M;
for (int i = 0; i < M; ++i) {
int u,v; cin>> u >> v; u--, v--;
lst[u].emplace_back(v,i), lst[v].emplace_back(u,i);
}
for (int i = 0; i < N; ++i) if (!visited[i]) dfs(i,0);
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |