QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#340895#999. 边双连通分量ffffyc#AC ✓40ms29352kbC++141.8kb2024-02-29 13:53:202024-02-29 13:53:40

Judging History

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

  • [2024-02-29 13:53:40]
  • 评测
  • 测评结果:AC
  • 用时:40ms
  • 内存:29352kb
  • [2024-02-29 13:53:20]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define ll long long
namespace IO{//by cyffff
	int len=0;
	char ibuf[(1<<21)+1],*iS,*iT,out[(1<<25)+1];
	#if ONLINE_JUDGE
	#define gh() (iS==iT?iT=(iS=ibuf)+fread(ibuf,1,(1<<21)+1,stdin),(iS==iT?EOF:*iS++):*iS++)
 	#else
	#define gh() getchar()
	#endif
	#define reg register
	inline int read(){
		reg char ch=gh();
		reg int x=0;
		reg char t=0;
		while(ch<'0'||ch>'9')   t|=ch=='-',ch=gh();
		while(ch>='0'&&ch<='9') x=x*10+(ch^48),ch=gh();
		return t?-x:x;
	}
	inline void putc(char ch){
		out[len++]=ch;
	}
	template<class T>
	inline void write(T x){
		if(x<0)putc('-'),x=-x;
		if(x>9)write(x/10);
		out[len++]=x%10+48;
	}
	inline void flush(){
		fwrite(out,1,len,stdout);
		len=0;
	}
	inline char getc(){
		char ch=gh();
		while(ch<'A'||ch>'Z') ch=gh();
		return ch;
	}
}
using IO::read;
using IO::write;
using IO::flush;
using IO::getc;
using IO::putc;
const int N=4e5+10;
int n,m,head[N],cnt=1;
struct Edge{
	int u,to,nxt;
}a[N<<1];
inline void add(int u,int v){
	a[++cnt]={u,v,head[u]},head[u]=cnt;
}
int dfn[N],low[N],tim,stk[N],top,blk;
bool vis[N<<1];
vector<int>poi[N];
inline void Tarjan(int x){
	low[x]=dfn[x]=++tim,stk[++top]=x;
	for(int i=head[x];i;i=a[i].nxt){
		if(vis[i]) continue;
		vis[i]=vis[i^1]=1;
		int t=a[i].to;
		if(!dfn[t]) Tarjan(t),low[x]=min(low[x],low[t]);
		else low[x]=min(low[x],dfn[t]);
	}
	if(low[x]==dfn[x]){
		blk++;
		while(1){
			int p=stk[top--];
			poi[blk].push_back(p);
			if(p==x) break;
		}
	}
}
int main(){
	n=read(),m=read();
	for(int i=1;i<=m;i++){
		int u=read()+1,v=read()+1;
		add(u,v),add(v,u);
	}
	for(int i=1;i<=n;i++)
		if(!dfn[i])
			Tarjan(i);
	write(blk),putc('\n');
	for(int i=blk;i;i--){
		write(poi[i].size()),putc(' ');
		for(auto tmp:poi[i]) write(tmp-1),putc(' ');
		putc('\n');
	}
	flush();
}

这程序好像有点Bug,我给组数据试试?

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 13000kb

input:

4 5
0 2
0 1
3 0
2 1
2 3

output:

1
4 1 2 3 0 

result:

ok OK

Test #2:

score: 0
Accepted
time: 2ms
memory: 12952kb

input:

13 21
4 5
8 7
12 3
3 10
1 5
10 2
0 0
11 4
2 12
9 1
9 0
7 8
7 6
9 1
8 2
12 10
11 0
8 6
3 2
5 9
4 11

output:

3
4 12 10 3 2 
3 7 6 8 
6 1 9 5 4 11 0 

result:

ok OK

Test #3:

score: 0
Accepted
time: 0ms
memory: 13056kb

input:

2 2
0 1
1 0

output:

1
2 1 0 

result:

ok OK

Test #4:

score: 0
Accepted
time: 30ms
memory: 29352kb

input:

200000 200000
127668 148778
77100 11865
85144 199231
39485 84917
102044 187263
130204 174776
26220 198288
162188 12078
92196 146334
120537 38083
150353 160479
18707 6545
101149 25450
62271 9177
38892 6454
11709 191939
89247 145109
140599 121858
197410 148980
55975 169098
128576 59852
68224 182347
89...

output:

105340
1 199975 
1 199964 
1 199958 
1 199957 
1 199954 
1 199951 
1 199947 
1 199946 
1 199939 
1 199937 
1 199933 
1 199925 
1 199915 
1 199913 
1 199904 
1 199903 
1 199889 
1 199877 
1 199865 
1 199862 
1 199844 
1 199834 
1 199832 
1 199827 
1 199825 
1 199824 
1 199821 
1 199820 
1 199814 
1 1...

result:

ok OK

Test #5:

score: 0
Accepted
time: 40ms
memory: 29332kb

input:

200000 200000
150762 148756
172967 108322
69862 125085
84513 111056
141009 156725
36311 103205
31879 79919
62895 63377
21697 115522
161610 160423
113104 10277
106927 168428
136657 198931
52292 164110
149020 7038
115111 112823
35584 124385
45429 191603
96444 30523
195578 149089
160105 58103
139792 27...

output:

104955
1 199996 
1 199981 
1 199969 
1 199963 
1 199956 
1 199952 
1 199945 
1 199944 
1 199938 
1 199937 
1 199926 
1 199925 
1 199914 
1 199912 
1 199900 
1 199893 
1 199884 
1 199875 
1 199853 
1 199839 
1 199838 
1 199833 
1 199827 
1 199826 
1 199822 
1 199820 
1 199809 
1 199806 
1 199802 
1 1...

result:

ok OK

Test #6:

score: 0
Accepted
time: 39ms
memory: 29304kb

input:

200000 200000
53335 120202
193029 92221
8244 61648
50176 7825
97274 91479
85438 76999
26861 80116
162826 198446
160509 95916
143190 116619
121254 192931
121545 132273
149400 91882
97032 5048
179008 82221
187475 70697
159074 65868
158744 94466
120006 170635
36429 162768
61114 17876
131798 188508
1080...

output:

105649
1 199995 
1 199990 
1 199988 
1 199973 
1 199972 
1 199963 
1 199941 
1 199932 
1 199925 
1 199921 
1 199902 
1 199899 
1 199894 
1 199890 
1 199863 
1 199851 
1 199849 
1 199845 
1 199842 
1 199841 
1 199837 
1 199833 
1 199828 
1 199821 
1 199817 
1 199804 
1 199803 
1 199787 
1 199784 
1 1...

result:

ok OK

Test #7:

score: 0
Accepted
time: 24ms
memory: 24328kb

input:

127669 148779
124640 77100
11865 117450
85144 68159
104241 39485
76372 84917
102044 56191
43704 26220
67216 31116
75749 123504
12078 92196
70006 15262
100591 74552
120537 38083
19281 29407
18707 6545
101149 25450
62271 9177
38892 6454
11709 119710
60867 89247
14037 9527
121858 66338
112298 81804
795...

output:

51131
1 127660 
1 127656 
1 127653 
1 127649 
1 127641 
1 127636 
1 127629 
1 127623 
1 127616 
1 127597 
1 127585 
1 127578 
1 127561 
1 127547 
1 127538 
1 127534 
1 127520 
1 127518 
1 127510 
1 127488 
1 127476 
1 127472 
1 127456 
1 127433 
1 127430 
1 127426 
1 127420 
1 127414 
1 127389 
1 12...

result:

ok OK

Test #8:

score: 0
Accepted
time: 27ms
memory: 25520kb

input:

150763 148757
108322 69862
125085 84513
111056 141009
36311 103205
31879 79919
62895 63377
21697 115522
113104 10277
106927 136657
52292 149020
7038 115111
112823 35584
124385 45429
96444 30523
149089 58103
139792 27250
15883 109949
69372 132387
141930 113408
65522 128254
138198 141969
42522 92075
1...

output:

81019
1 150761 
1 150759 
1 150757 
1 150754 
1 150751 
1 150745 
1 150744 
1 150734 
1 150728 
1 150716 
1 150714 
1 150711 
1 150706 
1 150704 
1 150703 
1 150698 
1 150697 
1 150680 
1 150676 
1 150667 
1 150654 
1 150653 
1 150639 
1 150632 
1 150620 
1 150608 
1 150602 
1 150597 
1 150596 
1 15...

result:

ok OK

Test #9:

score: 0
Accepted
time: 12ms
memory: 19824kb

input:

53336 120203
26685 8244
50176 7825
31738 24370
25943 19902
11463 26861
29977 26309
14580 31754
1838 29437
30380 12118
51083 31633
1201 18328
26346 5295
48935 19027
31496 19906
41783 5048
47936 16685
5161 34107
15907 28002
332 27672
28930 39563
36429 31696
17876 726
42526 21682
35319 8727
17974 25252...

output:

3392
1 53303 
1 53171 
1 53152 
1 53099 
1 53088 
1 53065 
1 52915 
1 52845 
1 52814 
1 52764 
1 52758 
1 52683 
1 52642 
1 52629 
1 52554 
1 52468 
1 52280 
1 52208 
1 52116 
1 51985 
1 51509 
1 51482 
1 51412 
1 51150 
1 51076 
1 50997 
1 50685 
1 50580 
1 50563 
1 50556 
1 50457 
1 50336 
1 50116...

result:

ok OK

Test #10:

score: 0
Accepted
time: 3ms
memory: 16232kb

input:

17707 71661
1354 3272
13699 17294
16733 9246
14993 5758
7252 2983
3813 6121
10450 14069
8088 11201
857 4420
12788 2032
11938 1465
10322 15171
14688 1857
2309 2742
2013 13200
14142 16319
10541 1922
10368 1516
7994 9092
3327 5166
13484 2876
15472 13522
15622 13479
3361 15314
15464 14974
17637 7535
435...

output:

75
1 15694 
1 11486 
1 11464 
1 8878 
1 8295 
1 7773 
1 7104 
1 4074 
1 3764 
1 2213 
1 1173 
16444 16855 14791 7351 1504 7018 6967 5690 9248 4212 4149 4645 17190 12453 898 15887 11963 5048 2994 1181 6559 1249 14241 11033 12557 7238 9618 8726 9170 17146 3966 1460 2277 12163 4230 15344 12885 11921 47...

result:

ok OK

Test #11:

score: 0
Accepted
time: 6ms
memory: 13764kb

input:

4294 17517
1175 3250
314 389
4272 3633
2938 1831
1307 2818
3321 347
1205 1428
2354 1478
1003 3898
1587 3443
1122 1512
2512 3995
348 3280
2064 1022
1834 2958
4281 1863
689 3613
2115 3708
1645 1488
1601 4181
916 4276
128 2626
4147 2868
87 1411
1802 1451
1254 2010
2936 3120
1065 277
1121 3284
3655 2849...

output:

29
1 651 
1 538 
3031 600 304 2478 3840 4293 196 1059 3103 4235 3967 3173 2618 1846 1040 765 3446 3661 3536 3373 3936 657 3085 3434 464 1588 3744 925 1234 2848 1342 3153 2846 643 660 55 447 3149 4101 725 636 2980 578 137 2568 3795 576 3615 1869 3068 3912 698 647 563 2888 3542 3613 1045 3378 1579 186...

result:

ok OK

Test #12:

score: 0
Accepted
time: 7ms
memory: 17668kb

input:

26686 105813
14774 5315
22701 21346
1398 13888
18566 18745
22298 6181
21347 10653
16500 23768
2329 5818
17512 16769
25519 338
12580 3064
19467 21665
3978 13202
23556 25178
195 9695
1472 13111
22925 24074
3026 13281
17666 14469
22007 18680
4159 13152
20431 23814
6671 10788
24433 13211
9794 12608
3264...

output:

137
1 23839 
1 21430 
1 20006 
1 18820 
1 17988 
1 13128 
1 11477 
1 10157 
1 9124 
1 8003 
480 17613 17745 16206 24250 22249 20716 19806 5954 8774 8858 13276 7600 13746 22781 20012 14601 1758 20695 14791 22557 6522 17211 17299 8889 17640 9679 22042 24505 15557 15214 20233 1875 5873 18175 9582 26026...

result:

ok OK

Test #13:

score: 0
Accepted
time: 16ms
memory: 19396kb

input:

36033 148595
33366 22486
14414 23855
2694 30361
16352 31902
27993 2048
4707 31743
30610 12884
23278 27069
10529 20914
2030 30015
24554 15673
10184 29423
17825 20383
34077 1181
25518 26129
6355 8810
2857 21736
25108 34280
14992 24299
32649 20227
34529 10407
23194 29913
10451 319
34666 8904
30811 3003...

output:

150
1 36018 
1 33412 
1 29037 
1 27599 
1 27491 
1 27298 
1 26809 
1 21349 
1 20980 
1 19707 
1 17658 
1 13229 
1 9959 
1 6307 
1 6085 
1 4840 
401 20951 28871 22549 16644 5457 35127 27992 24173 33420 9709 29483 32062 12458 949 13336 23424 21802 23514 22294 21531 27286 21912 27148 27938 34973 29940 ...

result:

ok OK

Test #14:

score: 0
Accepted
time: 4ms
memory: 15612kb

input:

14868 57739
5724 2103
9214 3074
2269 531
3811 13162
5199 12632
6337 12078
12592 4977
3553 6975
5063 6622
1221 13056
4252 3705
7547 7879
1702 3685
4058 2503
7540 9423
4280 12228
574 6265
11876 2711
4805 7605
1468 4802
6921 1954
6350 2733
4429 5862
13549 14543
13809 5357
1509 11478
87 2676
6299 7060
1...

output:

80
1 13102 
1 11254 
1 10166 
1 7703 
1 6014 
1 5600 
1 3277 
1 809 
5372 6357 11589 13946 2005 4808 7037 9365 717 13873 4195 1733 6498 9998 1491 13797 7305 2179 564 87 12186 8367 12835 5400 6008 13812 3678 9607 4191 8486 11247 3255 13226 2240 8554 11801 2734 2356 408 9079 14082 4932 13152 14392 342...

result:

ok OK

Test #15:

score: 0
Accepted
time: 0ms
memory: 13104kb

input:

53 43
32 44
25 10
24 49
20 28
28 44
16 12
37 48
46 36
30 47
25 3
17 31
19 17
29 42
25 44
30 3
31 21
2 34
42 12
22 50
12 52
39 10
0 46
29 1
12 21
3 0
11 31
42 25
4 51
26 36
19 48
39 26
5 21
7 41
29 34
38 47
29 8
26 17
42 46
36 20
39 30
13 27
28 31
27 24

output:

37
1 45 
1 43 
1 40 
1 35 
1 33 
1 23 
1 22 
1 50 
1 18 
1 15 
1 14 
1 13 
1 27 
1 24 
1 49 
1 9 
1 7 
1 41 
1 6 
1 4 
1 51 
17 10 21 12 20 36 46 42 25 44 28 31 17 26 39 30 3 0 
1 47 
1 38 
1 11 
1 32 
1 29 
1 1 
1 34 
1 2 
1 8 
1 16 
1 52 
1 5 
1 19 
1 48 
1 37 

result:

ok OK

Test #16:

score: 0
Accepted
time: 0ms
memory: 13040kb

input:

70 21
39 34
29 33
38 53
37 7
47 64
47 17
65 66
60 39
37 47
19 68
14 28
39 41
52 55
0 60
59 16
11 40
11 33
35 26
0 11
24 17
26 43

output:

70
1 69 
1 67 
1 65 
1 66 
1 63 
1 62 
1 61 
1 58 
1 57 
1 56 
1 54 
1 52 
1 55 
1 51 
1 50 
1 49 
1 48 
1 46 
1 45 
1 44 
1 42 
1 38 
1 53 
1 36 
1 32 
1 31 
1 30 
1 27 
1 26 
1 35 
1 43 
1 25 
1 23 
1 22 
1 21 
1 20 
1 19 
1 68 
1 18 
1 16 
1 59 
1 15 
1 14 
1 28 
1 13 
1 12 
1 10 
1 9 
1 8 
1 7 
...

result:

ok OK

Test #17:

score: 0
Accepted
time: 5ms
memory: 13032kb

input:

88 139
5 61
52 80
0 17
50 87
62 71
25 69
10 46
44 86
11 38
17 35
73 49
24 47
39 83
8 66
55 56
64 45
83 41
59 35
76 24
2 70
11 77
80 58
84 86
30 50
23 54
36 74
12 10
62 75
33 34
43 28
77 29
10 46
77 33
26 48
32 38
52 79
15 30
25 57
86 0
46 75
81 60
35 83
66 87
25 86
19 85
9 38
15 64
59 82
0 53
40 66
...

output:

16
1 51 
1 16 
73 43 67 84 40 69 63 19 29 64 44 58 26 80 65 32 76 24 59 10 46 8 4 75 71 62 3 78 52 87 50 30 85 38 11 36 27 35 83 39 79 48 15 66 86 25 81 60 23 41 22 14 77 73 33 21 2 7 9 6 49 70 17 56 55 1 5 37 28 57 61 20 72 0 
1 53 
1 42 
1 34 
1 54 
1 13 
1 68 
1 74 
1 45 
1 47 
1 18 
1 12 
1 82 
...

result:

ok OK

Test #18:

score: 0
Accepted
time: 5ms
memory: 13092kb

input:

53 185
48 40
23 7
45 7
6 42
13 6
45 1
18 28
47 14
11 15
27 9
50 44
23 47
20 27
18 19
2 19
18 49
32 49
9 12
11 0
32 49
22 14
8 48
41 28
30 43
4 21
7 22
28 30
17 11
19 30
44 7
46 8
50 45
35 48
29 47
4 26
16 39
37 25
38 12
19 52
28 41
23 31
33 34
6 15
44 24
0 6
26 22
49 43
4 31
20 38
43 39
41 39
51 40
...

output:

3
17 32 33 30 16 41 37 34 28 19 36 39 52 49 25 18 43 2 
20 12 20 3 51 10 46 35 48 27 38 6 15 11 40 9 42 13 17 8 0 
16 7 23 31 45 4 22 47 44 26 5 50 29 14 1 24 21 

result:

ok OK

Test #19:

score: 0
Accepted
time: 0ms
memory: 13024kb

input:

70 252
63 36
64 48
26 34
43 37
30 53
67 64
26 19
25 54
28 44
52 60
4 22
43 48
14 48
12 50
37 23
28 40
48 54
60 23
43 46
7 5
29 39
5 13
57 60
1 23
33 8
59 39
3 29
5 8
34 11
44 40
39 19
40 17
42 48
39 19
49 46
0 48
46 45
57 67
43 60
56 59
32 42
6 54
56 69
23 43
38 65
66 24
0 64
16 10
23 1
4 16
37 49
5...

output:

1
70 20 58 27 40 28 4 16 63 36 10 24 47 66 46 37 1 57 23 42 15 64 60 6 3 34 19 69 13 9 68 26 21 18 30 35 7 11 59 29 50 39 5 33 12 2 62 56 41 53 8 61 55 38 17 44 31 65 22 67 48 49 45 43 14 54 51 32 25 52 0 

result:

ok OK

Test #20:

score: 0
Accepted
time: 5ms
memory: 12960kb

input:

88 390
74 40
14 37
44 66
7 49
12 4
39 48
56 76
46 40
80 30
5 39
52 0
40 79
0 11
34 41
43 80
54 62
61 41
54 37
31 81
59 66
23 59
47 84
16 85
68 29
31 63
4 55
27 5
26 68
14 84
16 34
82 16
62 54
46 15
65 63
58 83
5 36
67 19
65 42
35 25
82 73
55 59
28 36
22 38
46 79
61 34
51 40
69 42
36 5
26 38
86 14
22...

output:

3
76 42 71 85 16 34 57 41 61 82 2 72 30 80 43 1 73 66 59 44 4 23 55 53 12 26 68 22 38 29 51 40 17 79 74 46 15 3 18 70 83 58 21 32 35 87 25 19 67 81 13 31 8 63 65 69 10 62 37 54 47 78 84 14 7 28 86 24 64 6 50 49 11 75 45 52 0 
6 9 76 56 33 77 20 
6 48 60 39 5 27 36 

result:

ok OK