QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#481137#995. 桥Sktn0089#RE 0ms0kbC++141.0kb2024-07-16 20:44:022024-07-16 20:44:02

Judging History

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

  • [2024-07-16 20:44:02]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:0kb
  • [2024-07-16 20:44:02]
  • 提交

answer

#include <bits/stdc++.h>
#define ll long long
#define pir pair <ll, ll>
#define mkp make_pair
#define fi first
#define se second
#define pb push_back
using namespace std;
const ll maxn = 5e5 + 10;
ll n, m, x[maxn], y[maxn], ans[maxn], len;
struct edge { ll v, nxt, id; } e[maxn];
ll head[maxn], tot, dfn[maxn], low[maxn], ti;
void ins(ll u, ll v, ll i) {
	e[++tot] = (edge) {v, head[u], i};
	head[u] = tot;
}
void tarjan(ll u, ll p) {
	dfn[u] = low[u] = ++ti;
	for(ll i = head[u]; i; i = e[i].nxt) {
		ll v = e[i].v, id = e[i].id;
		if(id == p) continue;
		if(dfn[v]) low[u] = min(low[u], dfn[v]);
		else {
			tarjan(v, id);
			low[u] = min(low[u], low[v]);
			if(low[v] > dfn[u]) ans[++len] = id;
		}
	}
}
int main(){
	scanf("%lld%lld", &n, &m);
	for(ll i = 1; i <= m; i++) {
		scanf("%lld%lld", x + i, y + i);
		ins(x[i], y[i], i), ins(y[i], x[i], i);
	}
	for(ll i = 1; i <= n; i++)
		if(!dfn[i]) tarjan(i, 0);
	sort(ans + 1, ans + 1 + len);
	for(ll i = 1; i <= len; i++)
		printf("%lld %lld\n", x[ans[i]], y[ans[i]]);
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

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:

12556 333341
22581 333343
9700 650152
10074 333346
16990 8951
10698 664179
23086 4312
2513 6666
16607 617137
16607 617137
16366 333349
9397 6962
17463 663139
18960 10068
442 333354
11839 16422
678 23252
11744 333356
3255 621440
19248 333358
20425 333358
20425 333358
17160 333359
16647 649702
12184 3...

result: