QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#220148 | #995. 桥 | luyiming123 | WA | 73ms | 21724kb | C++14 | 855b | 2023-10-19 22:42:48 | 2023-10-19 22:42:49 |
Judging History
answer
# include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
vector <pair<int,int> > g[N];
pair<int,int> E[N * 5];
int n, m;
int dfn[N], low[N], dfntot = 0;
bool ok[N];
void tarjan(int x, int lst)
{
dfn[x] = low[x] = ++dfntot;
for(auto I : g[x])
{
int v = I.first, id = I.second;
if(id == lst) continue;
if(!dfn[v]) tarjan(v, id), low[x] = min(low[x], low[v]);
else low[x] = min(low[x], dfn[v]);
if(low[v] > dfn[x])
{
ok[id] = 1;
}
}
}
int main(void)
{
scanf("%d%d", &n, &m);
for(int i = 1; i <= m; i++)
{
int u, v; scanf("%d%d", &u, &v);
g[u].push_back({v, i}), g[v].push_back({u, i});
E[i] = {u, v};
}
for(int i = 1; i <= n; i++) if(!dfn[i]) tarjan(i, 0);
for(int i = 1; i <= m; i++)
{
if(ok[i]) printf("%d %d\n", E[i].first, E[i].second);
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 73ms
memory: 21724kb
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:
21242 2692 3443 6209 22780 13125 991 17687 9286 6883 23795 13972 22557 18652 16688 13779 18920 18105 22950 16771 933 10208 22568 14839 19722 16043 18150 1031 22268 11061 11900 22749 23582 22262 3481 21090 5204 18754 8120 24916 5969 16716 13553 1844 24307 7827 16354 2894 4245 7266 10363 3013 19375 11...
result:
wrong output format Extra information in the output file