#include <bits/stdc++.h>
using namespace std;
#define int long long
const int N = 1e5 + 10;
int n, m, k;
vector<int> g[N];
int mt[N];
bool mark[N];
bool dfs(int u) {
if(mark[u]) return false;
mark[u] = true;
for(int v : g[u]) {
if(mt[v] == -1 || dfs(mt[v])) {
mt[v] = u;
return true;
}
}
return false;
}
int max_matching(int l, int r) {
for(int i = 1; i <= m; i++) mt[i] = -1;
int ans = 0;
for(int i = l; i <= r; i++) {
for(int j = l; j <= r; j++) mark[i] = false;
dfs(i);
}
for(int i = 1; i <= m; i++) if(mt[i] != -1) ans++;
return ans;
}
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cin >> n >> m >> k;
if(n > 100 || m > 50) assert(false);
for(int i = 1; i <= k; i++) {
int u, v;
cin >> u >> v;
g[u].push_back(v);
}
int ans = 0;
for(int l = 1; l <= n; l++) for(int r = l + m - 1; r <= n; r++) if(max_matching(l, r) == m) ans++;
cout << ans;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
3420 KB |
Output isn't correct |
2 |
Incorrect |
1 ms |
3420 KB |
Output isn't correct |
3 |
Incorrect |
1 ms |
3420 KB |
Output isn't correct |
4 |
Incorrect |
1 ms |
3420 KB |
Output isn't correct |
5 |
Correct |
1 ms |
3420 KB |
Output is correct |
6 |
Correct |
1 ms |
3420 KB |
Output is correct |
7 |
Incorrect |
1 ms |
3420 KB |
Output isn't correct |
8 |
Correct |
1 ms |
3508 KB |
Output is correct |
9 |
Correct |
1 ms |
3420 KB |
Output is correct |
10 |
Correct |
1 ms |
3420 KB |
Output is correct |
11 |
Incorrect |
1 ms |
3420 KB |
Output isn't correct |
12 |
Correct |
1 ms |
3420 KB |
Output is correct |
13 |
Correct |
1 ms |
3420 KB |
Output is correct |
14 |
Incorrect |
1 ms |
3420 KB |
Output isn't correct |
15 |
Incorrect |
1 ms |
3420 KB |
Output isn't correct |
16 |
Incorrect |
1 ms |
3420 KB |
Output isn't correct |
17 |
Correct |
1 ms |
3420 KB |
Output is correct |
18 |
Correct |
1 ms |
3420 KB |
Output is correct |
19 |
Incorrect |
2 ms |
3420 KB |
Output isn't correct |
20 |
Incorrect |
1 ms |
3420 KB |
Output isn't correct |
21 |
Correct |
2 ms |
3420 KB |
Output is correct |
22 |
Incorrect |
1 ms |
3420 KB |
Output isn't correct |
23 |
Correct |
2 ms |
3520 KB |
Output is correct |
24 |
Correct |
2 ms |
3416 KB |
Output is correct |
25 |
Runtime error |
4 ms |
6744 KB |
Execution killed with signal 6 |
26 |
Runtime error |
4 ms |
6748 KB |
Execution killed with signal 6 |
27 |
Runtime error |
3 ms |
6744 KB |
Execution killed with signal 6 |
28 |
Runtime error |
6 ms |
6748 KB |
Execution killed with signal 6 |
29 |
Runtime error |
3 ms |
6748 KB |
Execution killed with signal 6 |
30 |
Runtime error |
3 ms |
6760 KB |
Execution killed with signal 6 |
31 |
Runtime error |
3 ms |
6744 KB |
Execution killed with signal 6 |
32 |
Runtime error |
3 ms |
6744 KB |
Execution killed with signal 6 |
33 |
Runtime error |
3 ms |
6744 KB |
Execution killed with signal 6 |
34 |
Runtime error |
3 ms |
6744 KB |
Execution killed with signal 6 |
35 |
Runtime error |
3 ms |
6748 KB |
Execution killed with signal 6 |
36 |
Runtime error |
3 ms |
6608 KB |
Execution killed with signal 6 |
37 |
Runtime error |
3 ms |
6748 KB |
Execution killed with signal 6 |
38 |
Runtime error |
3 ms |
6748 KB |
Execution killed with signal 6 |
39 |
Runtime error |
3 ms |
6744 KB |
Execution killed with signal 6 |
40 |
Runtime error |
4 ms |
6748 KB |
Execution killed with signal 6 |
41 |
Runtime error |
3 ms |
6748 KB |
Execution killed with signal 6 |
42 |
Runtime error |
3 ms |
6748 KB |
Execution killed with signal 6 |
43 |
Runtime error |
3 ms |
6748 KB |
Execution killed with signal 6 |
44 |
Runtime error |
3 ms |
6748 KB |
Execution killed with signal 6 |
45 |
Runtime error |
3 ms |
6748 KB |
Execution killed with signal 6 |
46 |
Runtime error |
4 ms |
6748 KB |
Execution killed with signal 6 |
47 |
Runtime error |
3 ms |
6748 KB |
Execution killed with signal 6 |
48 |
Runtime error |
3 ms |
6808 KB |
Execution killed with signal 6 |
49 |
Runtime error |
3 ms |
6748 KB |
Execution killed with signal 6 |
50 |
Runtime error |
3 ms |
6748 KB |
Execution killed with signal 6 |