QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#470806#995. 桥KiharaTouma#WA 63ms25588kbC++231.3kb2024-07-10 16:32:062024-07-10 16:32:07

Judging History

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

  • [2024-07-10 16:32:07]
  • 评测
  • 测评结果:WA
  • 用时:63ms
  • 内存:25588kb
  • [2024-07-10 16:32:06]
  • 提交

answer

//qoj995 tarjan-bridge
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

const int N = 1e5, M = 1e6 + 10;
int n, m, ex[M], ey[M];
int hd[N], eg[M], nx[M], tot = 1;
int dfn[N], low[N], cnt, isb[M], vis[M];

void add(int u, int v){
	eg[++tot] = v;
	nx[tot] = hd[u];
	hd[u] = tot;
}
// void tg(int x){
	// dfn[x] = low[x] = ++ cnt;
	// for(int i = hd[x]; i; i = nx[i]){
		// if(vis[i]){
			// continue;
		// }
		// int y = eg[i];
		// vis[i] = vis[i^1] = 1;
		// if(!dfn[y]){
			// tg(y);
			// low[x] = min(low[x], low[y]);
			// if(low[y] > dfn[x]){
				// isb[i] = 1;
			// }
		// } else {
			// low[x] = min(low[x], dfn[y]);
		// }
	// }
// }

void tg(int x){
	low[x] = dfn[x] = ++ cnt;
	for(int i = hd[x]; i; i = nx[i]){
		if(vis[i]) continue;
		int y = eg[i];
		vis[i] = vis[i^1] = 1;
		if(!dfn[y]){
			tg(y);
			low[x] = min(low[x], low[y]);
			if(low[y] > dfn[x]){
				isb[i] = 1;
			}
		} else if(dfn[y] < dfn[x]){
			low[x] = min(low[x], dfn[y]);
		}
	}
}

int main(){
	scanf("%d%d", &n, &m);
	for(int i = 1; i <= m; ++ i){
		int u, v;
		scanf("%d%d", &u, &v);
		add(u, v);
		add(v, u);
		ex[i] = u;
		ey[i] = v;
	}
	for(int i = 1; i <= n; ++ i){
		if(!dfn[i]){
			tg(i);
		}
	}
	for(int i = 1; i <= m; ++ i){
		if(isb[i*2]){
			printf("%d %d\n", ex[i], ey[i]);
		}
	}
	return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 63ms
memory: 21896kb

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:

ok 0 lines

Test #2:

score: 0
Accepted
time: 14ms
memory: 17464kb

input:

10599 87159
4698 4000
60 4705
1476 5947
7273 1716
8004 3018
10094 1717
3092 3493
2613 9681
5427 3723
2510 6343
10113 6322
9257 634
4996 10197
9918 5582
6348 9561
10536 9777
8133 540
1917 7838
6666 2220
7951 815
2873 977
9397 4991
3529 1395
1426 3874
6379 9098
9504 3437
9076 9134
4321 3879
10252 9390...

output:


result:

ok 0 lines

Test #3:

score: -100
Wrong Answer
time: 16ms
memory: 25588kb

input:

43236 126833
40500 20695
21481 27642
28098 41772
412 7750
5862 39561
21777 22303
7868 21217
31658 34299
18532 10934
21931 31023
42926 15624
40332 18017
12484 8663
21927 7910
12504 17943
4379 10252
3523 21794
18641 1965
18633 25061
14639 10800
35958 1441
35044 20249
31491 38161
5749 4468
13403 8413
3...

output:

38008 17235
40329 42530
19516 26641
43027 24643
29027 35410
35388 534
30628 31979
38444 33887
28554 31809
39630 34623
16150 42137
13811 35147
3120 17275
36681 294
28872 23185
34632 38375
33548 29449
4954 1043
38501 561
28012 22768
15633 12291
40368 37763
17669 24284
36038 12307
27702 24596
18937 576...

result:

wrong answer 1st lines differ - expected: '1349 20915', found: '38008 17235'