QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#480540#898. 二分图最大匹配wdnmdwrnmmp#AC ✓419ms27792kbC++142.0kb2024-07-16 16:26:232024-07-16 16:26:23

Judging History

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

  • [2024-07-16 16:26:23]
  • 评测
  • 测评结果:AC
  • 用时:419ms
  • 内存:27792kb
  • [2024-07-16 16:26:23]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
// #define int long long
#define rep(i,j,k) for(int i=(j);i<=(k);i++)
#define per(i,j,k) for(int i=(j);i>=(k);i--)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
typedef vector<int> vi;
typedef pair<int,int> pi;

namespace flow{
	const int N=2e5+5, M=4e5+5, inf=1e9;
	int n,m=2,S,T;
	int bg[N];
	array<int,3> E[M*2];
	void link(int u,int v){
		E[m]={v,1,bg[u]}; bg[u]=m++;
		E[m]={u,0,bg[v]}; bg[v]=m++;
	}
	int dis[N], cur[N];
	int Q[N], head, tail;
	bool bfs(){
		fill(dis, dis+n+1, -1);
		dis[S]=0;
		head=tail=1, Q[1]=S;
		while(head<=tail){
			int u=Q[head++];
			for(int id=bg[u]; id; id=E[id][2]){
				int v=E[id][0], w=E[id][1];
				if(w && dis[v]==-1){
					dis[v]=dis[u]+1;
					cur[v]=bg[v];
					if(v==T){
						return true;
					}
					Q[++tail]=v;
				}
			}
		}
		return false;
	}
	int dfs(int u,int rst){
		if(u==S){
			return rst;
		}
		int pre=rst;
		for(int &id=cur[u]; id; id=E[id][2]){
			int v=E[id][0], w=E[id^1][1];
			if(dis[v]+1==dis[u] && w){
				int f=dfs(v, min(rst, w));
				E[id][1]+= f, E[id^1][1]-= f, rst-= f;
				if(!rst){
					break;
				}
			}
		}
		return pre-rst;
	}
	int dinic(){
		int res=0;
		while(bfs()){
			res+= dfs(T, inf);
		}
		return res;
	}
	void output(int _L){
		for(int id=bg[S]; id; id=E[id][2]){
			int v=E[id][0], w=E[id][1];
			if(w==0){
				for(int _id=bg[v]; _id; _id=E[_id][2]){
					if(E[_id][1]==0){
						cout<< v-1 <<' '<< E[_id][0]-_L-1 <<'\n';
					}
				}
			}
		}
	}
}
signed main(){
  	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  	
  	int L,R,m; cin>>L>>R>>m;
  	flow::n=L+R+2, flow::S=L+R+1, flow::T=L+R+2;
  	rep(i,1,L){
  		flow::link(flow::S, i);
  	}
  	rep(i,1,R){
  		flow::link(L+i, flow::T);
  	}
  	rep(i,1,m){
  		int u,v; cin>>u>>v;
  		u++, v++;
  		flow::link(u, L+v);
  	}
  	int ans=flow::dinic();
  	cout<< ans <<'\n';
  	flow::output(L);
}

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

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 415ms
memory: 17916kb

input:

100000 100000 200000
78474 45795
32144 46392
92549 13903
73460 34144
96460 92850
56318 77066
77529 84436
76342 51542
77506 99268
76410 89381
1778 61392
43607 96135
84268 74827
14857 35966
32084 94908
19876 174
1481 94390
12423 55019
64368 92587
81295 7902
25432 46032
36293 61128
73555 84836
8418 102...

output:

100000
99999 47869
99998 31618
99997 82251
99996 94454
99995 85265
99994 45120
99993 49218
99992 37339
99991 75925
99990 82705
99989 88952
99988 10085
99987 50863
99986 83956
99985 60640
99984 98709
99983 12035
99982 93024
99981 24351
99980 57136
99979 73218
99978 37254
99977 84368
99976 26466
99975...

result:

ok OK

Test #2:

score: 0
Accepted
time: 389ms
memory: 18160kb

input:

100000 100000 200000
56815 52516
2576 76201
40377 1757
50463 66496
15833 50879
9828 16330
80692 9962
51095 17590
15870 35191
91301 65509
90774 57492
11890 8966
44786 41895
3386 35478
93470 47452
84803 93635
90745 34876
18201 38717
7472 34257
36580 19532
13248 27524
6441 69869
8821 61870
94536 67713
...

output:

100000
99999 19326
99998 81868
99997 87158
99996 48695
99995 50364
99994 28867
99993 63197
99992 14061
99991 5379
99990 59381
99989 88729
99988 12098
99987 33436
99986 58504
99985 2981
99984 13114
99983 88199
99982 56527
99981 22223
99980 2742
99979 92230
99978 44802
99977 37197
99976 85078
99975 41...

result:

ok OK

Test #3:

score: 0
Accepted
time: 1ms
memory: 5792kb

input:

4 4 7
1 1
2 2
0 0
3 1
1 2
2 0
3 2

output:

3
3 2
2 0
1 1

result:

ok OK

Test #4:

score: 0
Accepted
time: 34ms
memory: 16240kb

input:

100000 100000 199999
25370 25370
85964 85963
415 415
16796 16796
12437 12437
45409 45408
63005 63004
22155 22155
87828 87827
84013 84013
37307 37307
72324 72324
83703 83703
55390 55389
6780 6779
78090 78090
9375 9375
82192 82192
74694 74694
49841 49841
15798 15798
69855 69854
82948 82947
97389 97388...

output:

100000
99999 99999
99998 99998
99997 99997
99996 99996
99995 99995
99994 99994
99993 99993
99992 99992
99991 99991
99990 99990
99989 99989
99988 99988
99987 99987
99986 99986
99985 99985
99984 99984
99983 99983
99982 99982
99981 99981
99980 99980
99979 99979
99978 99978
99977 99977
99976 99976
99975...

result:

ok OK

Test #5:

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

input:

100000 100000 199999
59469 59469
76773 76772
89516 89516
87040 87040
90184 90184
83075 83075
61454 61454
33615 33615
85794 85793
92072 92071
49725 49725
63842 63841
99247 99247
24121 24121
29552 29551
73533 73533
75845 75845
27029 27028
84418 84418
26636 26636
10100 10099
75013 75012
67341 67341
756...

output:

100000
99999 99999
99998 99998
99997 99997
99996 99996
99995 99995
99994 99994
99993 99993
99992 99992
99991 99991
99990 99990
99989 99989
99988 99988
99987 99987
99986 99986
99985 99985
99984 99984
99983 99983
99982 99982
99981 99981
99980 99980
99979 99979
99978 99978
99977 99977
99976 99976
99975...

result:

ok OK

Test #6:

score: 0
Accepted
time: 419ms
memory: 27792kb

input:

100000 100000 199999
22284 45795
32144 44930
58734 13903
57136 34144
7548 92850
56318 11874
77529 85278
27039 51542
77506 94257
69265 89381
67073 61392
86159 96135
83227 74827
14857 19500
32084 73639
86884 174
27268 94390
20020 55019
45357 92587
17833 7902
55801 46032
36293 46557
73555 13746
8418 88...

output:

100000
99999 47869
99998 31618
99997 82251
99996 94454
99995 85265
99994 45120
99993 49218
99992 37339
99991 75925
99990 82705
99989 88952
99988 10085
99987 50863
99986 83956
99985 60640
99984 98709
99983 12035
99982 93024
99981 24351
99980 57136
99979 73218
99978 37254
99977 84368
99976 26466
99975...

result:

ok OK

Test #7:

score: 0
Accepted
time: 382ms
memory: 21780kb

input:

100000 100000 199999
4850 52516
2576 29250
69016 1757
85854 66496
48300 50879
83741 16330
98931 9962
38730 17590
15870 13960
91301 97595
81692 57492
11890 59332
5076 41895
23574 35478
93470 65245
61976 93635
96140 34876
18201 35366
64057 34257
25588 19532
13248 91003
6441 83448
99191 61870
94536 169...

output:

100000
99999 19326
99998 81868
99997 87158
99996 48695
99995 50364
99994 28867
99993 63197
99992 14061
99991 5379
99990 59381
99989 88729
99988 12098
99987 33436
99986 58504
99985 2981
99984 13114
99983 88199
99982 56527
99981 22223
99980 2742
99979 92230
99978 44802
99977 37197
99976 85078
99975 41...

result:

ok OK

Test #8:

score: 0
Accepted
time: 55ms
memory: 15236kb

input:

61217 61379 199943
14003 13749
24504 24347
30371 30219
27661 27461
33247 33397
38346 38157
17300 16944
50476 50643
56488 56551
46690 46949
21355 21288
3899 3659
24330 24165
8806 8305
40957 40994
15089 14813
20397 20389
30864 30800
33635 33755
20900 20808
55447 55499
4335 4040
36726 36551
16496 16095...

output:

37154
61215 61366
61214 61369
61213 61371
61212 61373
61211 61370
61210 61368
61209 61372
61207 61378
61206 61367
61205 61374
61204 61376
61203 61377
61202 61375
61199 61356
61198 61352
61197 61361
61196 61364
61195 61360
61194 61357
61193 61359
61192 61363
61191 61365
61190 61362
61189 61355
61188 ...

result:

ok OK

Test #9:

score: 0
Accepted
time: 55ms
memory: 13676kb

input:

61352 60513 199960
2270 2419
38842 39327
48788 48843
2493 2635
40183 40659
59754 59010
48980 48993
52508 52276
12892 13195
33811 34565
40260 40700
2116 2289
11742 12133
29439 29942
4256 4392
51422 51263
44695 44994
21600 22165
21666 22208
26472 26785
49979 50038
12099 12515
10539 10816
32736 33401
3...

output:

37442
61351 60509
61350 60500
61349 60511
61348 60512
61347 60497
61346 60507
61345 60501
61344 60505
61343 60508
61342 60510
61341 60480
61338 60479
61336 60483
61335 60481
61334 60477
61333 60490
61332 60488
61331 60485
61330 60489
61328 60478
61327 60476
61326 60475
61325 60487
61324 60474
61323 ...

result:

ok OK

Test #10:

score: 0
Accepted
time: 92ms
memory: 16072kb

input:

100000 100000 199998
0 13805
0 33641
1 9259
1 62738
1 70691
1 78118
2 41148
3 15765
3 50059
4 96644
5 91521
6 32562
8 2550
8 11396
8 48345
9 14639
9 51057
9 79293
9 92374
10 64733
10 67020
11 7764
11 46822
11 60302
12 8749
12 27869
12 69569
12 71510
13 35684
13 42579
13 82023
14 34778
15 1975
15 693...

output:

78404
99999 11426
99998 70216
99997 43608
99996 92768
99995 19992
99994 92454
99993 44390
99992 59537
99991 93232
99990 41498
99989 20895
99988 67137
99987 94831
99986 12619
99985 85692
99984 14132
99983 61040
99982 67711
99981 79717
99979 99174
99978 86020
99977 83542
99976 9298
99975 96376
99973 3...

result:

ok OK

Test #11:

score: 0
Accepted
time: 89ms
memory: 16120kb

input:

100000 100000 199998
0 28389
0 41333
0 66666
1 5984
1 15912
3 63753
3 77735
4 25015
4 30450
4 90212
5 66978
5 98909
6 63465
6 78227
6 78950
6 85422
7 1743
7 1868
7 55171
8 37582
9 26491
9 82984
10 29229
10 29811
10 33063
11 10609
11 48601
11 73298
11 95658
12 29064
12 50261
12 63186
12 68616
13 8683...

output:

78497
99999 62187
99998 96454
99997 26421
99996 50142
99995 35708
99993 74043
99992 22046
99990 15692
99989 84125
99988 40218
99987 99134
99985 17561
99984 77189
99983 72586
99982 98561
99981 96749
99980 50831
99977 68664
99976 40116
99975 31225
99974 8519
99973 70817
99971 45519
99970 77670
99969 9...

result:

ok OK

Test #12:

score: 0
Accepted
time: 91ms
memory: 16068kb

input:

100000 100000 199997
0 4357
0 35525
0 51857
1 57468
1 94927
1 96004
3 75468
4 20202
4 37102
5 32207
6 8677
6 16775
6 46813
6 75640
7 30806
8 4099
8 26454
8 49376
8 55539
8 67032
9 82362
10 11387
10 33778
10 35352
10 50533
10 54706
11 44868
11 59104
14 80528
14 90600
14 99752
15 10954
15 80519
15 873...

output:

78379
99999 90013
99998 10250
99997 38112
99996 10551
99995 13678
99992 76624
99991 69457
99989 95870
99988 17851
99987 46736
99986 21587
99984 28568
99983 26018
99982 48970
99980 81438
99979 15996
99978 81499
99977 28411
99976 92189
99975 3704
99974 83635
99973 71086
99972 49035
99971 22416
99970 7...

result:

ok OK

Test #13:

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

input:

17707 77101 11866
4 29611
4 62770
4 65605
5 22177
5 57724
14 59632
14 68649
17 9622
18 9221
18 43355
29 19612
30 44428
32 51277
34 53196
35 20939
37 68142
38 34663
38 36432
39 71932
40 62217
41 40291
43 53542
44 22018
44 60539
47 56819
47 76081
49 18326
50 52876
50 58006
51 64709
51 66011
52 26751
5...

output:

8453
17706 27907
17704 11561
17701 39050
17700 51779
17698 37984
17697 49085
17696 64575
17694 65793
17692 6958
17691 51632
17688 64064
17687 53828
17685 76387
17683 33438
17682 35765
17681 61120
17680 18976
17679 40451
17676 29182
17675 42057
17673 27252
17671 25910
17667 28074
17665 5854
17663 158...

result:

ok OK

Test #14:

score: 0
Accepted
time: 29ms
memory: 12644kb

input:

69830 19691 148749
0 8565
0 12093
0 12608
2 777
2 8771
3 6106
3 7526
3 10596
3 12199
3 14674
3 17676
4 4643
4 15016
4 17194
6 6948
7 1743
7 7750
8 2305
8 4814
9 4468
9 12246
9 16763
9 17448
10 295
10 12043
10 13971
11 168
11 4447
11 7762
11 15833
11 15993
12 1914
12 3080
12 5649
14 29
15 1675
15 464...

output:

19684
69829 16203
69828 8362
69827 9450
69824 18968
69822 16472
69821 3073
69820 6586
69817 16763
69816 15755
69813 7937
69812 15167
69811 6607
69810 16484
69809 13927
69808 17694
69807 4180
69806 7362
69804 19552
69803 18852
69801 19601
69800 12109
69799 16277
69798 18411
69797 6097
69796 12910
697...

result:

ok OK

Test #15:

score: 0
Accepted
time: 34ms
memory: 11000kb

input:

53336 61958 92222
0 23730
0 34075
0 35525
1 30468
1 61015
3 24509
3 36308
4 8061
4 45185
4 54435
5 32530
5 59288
6 10104
6 56657
10 2203
10 3106
10 33778
11 29821
11 59104
12 27897
14 18850
15 13472
15 14983
15 37131
15 40140
15 49346
15 59901
16 12876
16 32645
18 26571
21 60370
22 39980
22 41044
22...

output:

40194
53334 35274
53333 37902
53332 51039
53330 37829
53329 60330
53326 43036
53325 24405
53321 3510
53320 53527
53319 33896
53318 52418
53316 16890
53315 6335
53314 45473
53313 58768
53312 2602
53311 40466
53310 41768
53309 52929
53308 24471
53307 47517
53306 41806
53304 17543
53301 3312
53300 3554...

result:

ok OK

Test #16:

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

input:

36033 25839 130375
0 1577
0 16725
0 22301
0 24558
1 5977
1 6738
1 9339
1 25294
2 762
2 6992
2 10207
2 14608
3 3
3 3002
3 25047
4 12402
4 13815
4 15862
5 4727
6 6680
6 8345
6 10057
6 13352
6 17084
7 9878
7 17893
7 21628
7 23892
8 2601
8 13004
8 19099
8 23028
9 2307
9 13011
9 15776
9 22642
11 7388
11 ...

output:

25668
36032 21425
36031 21252
36030 1306
36029 23366
36028 24122
36027 22083
36026 24885
36025 3917
36024 23955
36023 19658
36022 15680
36021 23816
36020 19202
36019 13973
36018 23269
36017 20606
36016 23001
36015 22866
36014 17847
36013 16732
36012 22544
36011 12713
36010 21712
36009 3173
36008 155...

result:

ok OK

Test #17:

score: 0
Accepted
time: 9ms
memory: 10632kb

input:

14868 99117 25214
0 19546
0 37951
1 13804
1 18263
1 38541
1 49319
1 64693
1 81665
1 91777
2 2159
2 8896
4 38134
5 3464
5 52631
6 85971
6 92674
7 5530
7 12991
7 35465
8 12077
8 71946
9 57520
11 75486
11 95227
12 83001
13 83429
13 85532
15 32388
15 49234
15 87159
16 70733
16 95797
17 45027
18 51284
20...

output:

12003
14867 53690
14866 90857
14865 14542
14864 84296
14861 90333
14859 89792
14858 68709
14857 62021
14856 83357
14855 12490
14854 48979
14853 25334
14852 46353
14851 26088
14850 85037
14849 4772
14844 61342
14843 92509
14841 27929
14840 73126
14839 33637
14838 93679
14836 48507
14834 20973
14833 4...

result:

ok OK

Test #18:

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

input:

53098 9437 57924
0 262
0 3336
0 7251
2 2976
3 4877
4 3403
4 8279
5 4742
6 2961
6 8901
8 5979
8 8808
9 7822
10 415
12 969
13 1058
15 3592
17 5759
18 7128
19 4461
19 9343
20 5011
20 8942
21 8414
22 5217
22 5266
22 5455
23 5698
23 8697
24 5855
25 1211
25 2830
28 3685
29 1866
29 8645
32 6955
32 7045
33 ...

output:

9415
53096 2682
53093 4174
53092 4282
53091 9400
53090 6411
53089 6158
53088 1219
53087 5382
53086 8152
53085 3048
53084 7863
53082 6346
53081 3622
53076 6490
53075 8874
53074 6744
53073 7455
53072 1066
53071 6925
53070 3214
53069 5954
53067 7005
53066 6911
53064 1790
53063 9255
53062 6896
53061 880...

result:

ok OK

Test #19:

score: 0
Accepted
time: 91ms
memory: 12820kb

input:

62342 62612 153201
0 1819
1 26257
1 34654
1 41966
2 9609
3 19007
3 31306
3 36054
4 36681
4 42043
4 46885
4 54123
5 35272
5 48535
6 9177
6 44477
7 11189
7 17566
7 41426
7 53724
8 13815
8 36015
8 48166
10 1144
10 2928
10 21148
10 21677
10 46645
12 39907
12 53275
13 52579
14 21089
15 39807
16 46513
17 ...

output:

53671
62341 9852
62340 7649
62339 49041
62338 34772
62337 2727
62336 31971
62335 52867
62334 49466
62333 43614
62332 47284
62330 13811
62329 1432
62328 4792
62326 17390
62325 17504
62324 29209
62323 51982
62322 32750
62321 43663
62320 20370
62319 21868
62318 42775
62317 29467
62316 34905
62315 26465...

result:

ok OK

Test #20:

score: 0
Accepted
time: 11ms
memory: 9116kb

input:

95835 11475 31126
7 7489
10 1813
17 1852
18 9253
21 2999
25 1649
28 7088
33 4068
33 6119
34 5651
39 10350
41 5703
43 7512
51 3934
52 4246
55 4275
55 6549
64 8185
66 10080
67 10332
73 6343
73 6432
80 8844
86 1764
87 5646
92 399
95 509
95 9564
102 10598
107 582
121 5613
122 5866
123 7063
125 4180
125 ...

output:

10716
95834 2064
95830 5831
95821 11343
95818 6700
95815 10842
95813 5631
95812 303
95810 10969
95809 5988
95807 10850
95806 6319
95804 10084
95801 168
95800 569
95799 6586
95796 5378
95793 3456
95792 11291
95788 5871
95786 2779
95775 1184
95774 2507
95773 9181
95772 8292
95771 5564
95770 1262
95764...

result:

ok OK

Test #21:

score: 0
Accepted
time: 22ms
memory: 12584kb

input:

5824 49455 192460
0 451
0 2959
0 4380
0 4902
0 9092
0 9318
0 10189
0 11109
0 13730
0 15872
0 17604
0 18557
0 19327
0 19871
0 21171
0 24112
0 26985
0 28368
0 28474
0 29569
0 30903
0 31861
0 35960
0 36791
0 38654
0 40350
0 46164
0 46921
0 47526
0 48226
0 48323
0 48592
0 49186
1 2866
1 8429
1 9731
1 98...

output:

5824
5823 48435
5822 43876
5821 47847
5820 49311
5819 48828
5818 49367
5817 47470
5816 46277
5815 49037
5814 48343
5813 48540
5812 48978
5811 48826
5810 48561
5809 48909
5808 47769
5807 48086
5806 48691
5805 46559
5804 48430
5803 46428
5802 48238
5801 48572
5800 48409
5799 48855
5798 48738
5797 4897...

result:

ok OK

Test #22:

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

input:

64506 23320 150593
0 4768
0 10542
0 14842
0 20602
1 1266
1 12253
2 471
2 13145
2 14023
2 15190
2 18272
2 22689
4 8149
4 9069
6 357
6 10397
6 10869
6 16797
7 5497
7 19179
8 3468
8 6448
8 11473
8 12455
8 13155
9 751
10 11245
11 10586
11 13266
11 17148
11 20206
11 22535
12 5515
13 374
13 19047
14 11867...

output:

23290
64503 18334
64502 19132
64501 6609
64500 21177
64498 16869
64497 11593
64496 17400
64495 16487
64494 8778
64493 21307
64491 22880
64490 11423
64489 18010
64488 13956
64487 11986
64485 19752
64484 22426
64483 22258
64482 14429
64481 20297
64480 19350
64479 7519
64478 12167
64477 23227
64476 150...

result:

ok OK