QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#340798 | #995. 桥 | alpha1022 | WA | 22ms | 11832kb | C++14 | 853b | 2024-02-29 12:23:20 | 2024-02-29 12:23:21 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5;
int n, m;
pair<int, int> edge[N + 5];
bool bridge[N + 5];
vector<pair<int, int>> e[N + 5];
int id[N + 5], low[N + 5], dfnTot, efa[N + 5];
void tarjan(int u) {
id[u] = low[u] = ++dfnTot;
for (auto [v, eid]: e[u])
if (!id[v]) {
efa[v] = eid, tarjan(v);
if (low[v] > id[u]) bridge[eid] = 1;
else low[u] = min(low[u], low[v]);
} else if (eid != efa[u]) low[u] = min(low[u], id[v]);
}
int main() {
scanf("%d%d", &n, &m);
for (int i = 1; i <= m; ++i) {
auto &[u, v] = edge[i]; scanf("%d%d", &u, &v);
e[u].emplace_back(v, i), e[v].emplace_back(u, i);
}
for (int i = 1; i <= n; ++i)
if (!id[i]) tarjan(i);
for (int i = 1; i <= m; ++i)
if (bridge[i]) { auto [u, v] = edge[i]; printf("%d %d\n", u, v); }
}
详细
Test #1:
score: 0
Wrong Answer
time: 22ms
memory: 11832kb
input:
24942 387166 12556 21443 22404 16376 11073 24296 1535 11968 23745 2818 5073 12731 22550 14761 24118 12008 22695 18979 15118 13639 2080 8721 692 22578 22581 15267 9278 4127 7457 21674 17693 23448 10949 23429 9700 6009 14140 5064 7742 15164 17336 1662 18903 9760 17645 19575 6540 11942 11 4937 15282 10...
output:
23086 9796 11649 13969 15710 11305 17825 4536 24043 4070 11329 8017 11641 11818 23345 12685 975 14740 11747 13836 1074 21620 20267 8205 22847 10889 9139 22269
result:
wrong output format Extra information in the output file