QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#789777#898. 二分图最大匹配_TLEer_#WA 71ms16936kbC++14744b2024-11-27 21:49:142024-11-27 21:49:21

Judging History

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

  • [2024-11-27 21:49:21]
  • 评测
  • 测评结果:WA
  • 用时:71ms
  • 内存:16936kb
  • [2024-11-27 21:49:14]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
int l,r,m,x,y,u[200010],v[200010];
vector<int> a[200010];
int cnt,pp[200010];
int dfs(int nw){
	for(auto it=a[nw].begin();it!=a[nw].end();){
		int v=*it;it=a[nw].erase(it);
		if(!pp[v]){
			pp[v]=nw;pp[nw]=v;
			cnt++;return 1;
		}
		else if(dfs(pp[v])){
			pp[v]=nw;pp[nw]=v;
			cnt++;return 1;
		}
	}
	return 0;
}
signed main(){
	ios::sync_with_stdio(false);
	cin.tie();cout.tie();
	cin>>l>>r>>m;
	for(int i=1;i<=m;i++){
		cin>>u[i]>>v[i];u[i]++;v[i]++;
		a[u[i]].emplace_back(v[i]+l);
		a[v[i]+l].emplace_back(u[i]);
	}
	for(int i=1;i<=l;i++)
		if(!pp[i])dfs(i);
	cout<<cnt<<'\n';
	for(int i=1;i<=l;i++)
		if(pp[i])cout<<i-1<<' '<<pp[i]-l-1<<'\n';
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 71ms
memory: 16936kb

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:

131237
0 54731
1 26066
2 28471
3 1717
4 99457
5 28330
6 55261
7 34703
8 68817
9 23249
10 31609
11 69580
12 53920
13 47593
14 99163
15 87183
16 12858
17 2814
18 46044
19 75228
20 4206
21 97167
22 60611
23 36775
24 66081
25 45592
26 3321
27 42953
28 68974
29 89214
30 48329
31 83162
32 46298
33 50041
3...

result:

wrong answer # of Matching is differ - expected: '100000', found '131237'