QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#220010#995. 桥zhangmingzuRE 0ms0kbC++141.1kb2023-10-19 20:41:482023-10-19 20:41:50

Judging History

你现在查看的是最新测评结果

  • [2023-10-19 20:41:50]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:0kb
  • [2023-10-19 20:41:48]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
vector<pair<int, int>> edge[maxn];
int gb[maxn], n, m, low[maxn], dfn[maxn], cnt;
map<pair<int, int>, int> os;
pair<int, int> pii[maxn];
void tarjan(int now, int fa)
{
    low[now] = dfn[now] = ++cnt;
    int sum = 0;
    for (auto i : edge[now])
        if (!dfn[i.first])
        {
            sum++;
            tarjan(i.first, now);
            low[now] = min(low[now], low[i.first]);
            if (dfn[now] < low[i.first]) gb[i.second] = 1;
        }
        else if (i.first != fa) low[now] = min(low[now], dfn[i.first]);
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    cin >> n >> m;
    for (int i = 1; i <= m; i++)
    {
        int u, v;
        cin >> u >> v;
        os[make_pair(u, v)]++;
        pii[i] = make_pair(u, v);
        edge[u].emplace_back(v, i);
        edge[v].emplace_back(u, i);
    }
    for (int i = 1; i <= n; i++)
        if (!dfn[i]) tarjan(i, 0);
    for (int i = 1; i <= m; i++) if (gb[i] && os[pii[i]] == 1) cout << pii[i].first << ' ' << pii[i].second << '\n';
    return 0;
}

详细

Test #1:

score: 0
Runtime Error

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:


result: