-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path218.cpp
47 lines (36 loc) · 866 Bytes
/
218.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
//
// Created by milad on 31.03.20.
//
# include <iostream>
using namespace std;
int N;
bool bpm(int u, bool seen[], int matchR[]) {
for (int v = 0; v < N; v++) {
if (bpGraph[u][v] && !seen[v]) {
seen[v] = true;
if (matchR[v] < 0 || bpm(bpGraph, matchR[v],
seen, matchR)) {
matchR[v] = u;
return true;
}
}
}
return false;
}
int maxBPM() {
int matchR[N];
memset(matchR, -1, sizeof(matchR));
int result = 0;
for (int u = 0; u < N; u++) {
bool seen[N];
memset(seen, 0, sizeof(seen));
if (bpm(u, seen, matchR))
result++;
}
return result;
}
int main() {
cout << "Maximum number of applicants that can get job is "
<< maxBPM(bpGraph);
return 0;
}