답안 #990449

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
990449 2024-05-30T12:39:41 Z DAleksa 결혼 문제 (IZhO14_marriage) C++17
32 / 100
1500 ms 5200 KB
#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;
    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;
}
# 결과 실행 시간 메모리 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 3420 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 3672 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 1 ms 3420 KB Output is correct
22 Incorrect 1 ms 3420 KB Output isn't correct
23 Correct 1 ms 3420 KB Output is correct
24 Correct 1 ms 3420 KB Output is correct
25 Incorrect 311 ms 3676 KB Output isn't correct
26 Incorrect 115 ms 3420 KB Output isn't correct
27 Correct 66 ms 3420 KB Output is correct
28 Incorrect 63 ms 3420 KB Output isn't correct
29 Correct 359 ms 3416 KB Output is correct
30 Correct 345 ms 3596 KB Output is correct
31 Incorrect 1313 ms 3928 KB Output isn't correct
32 Incorrect 424 ms 3420 KB Output isn't correct
33 Correct 348 ms 3504 KB Output is correct
34 Incorrect 334 ms 3508 KB Output isn't correct
35 Execution timed out 1560 ms 4444 KB Time limit exceeded
36 Execution timed out 1546 ms 4440 KB Time limit exceeded
37 Execution timed out 1579 ms 4188 KB Time limit exceeded
38 Execution timed out 1576 ms 4956 KB Time limit exceeded
39 Execution timed out 1523 ms 3416 KB Time limit exceeded
40 Execution timed out 1555 ms 3676 KB Time limit exceeded
41 Execution timed out 1520 ms 3864 KB Time limit exceeded
42 Execution timed out 1555 ms 3932 KB Time limit exceeded
43 Execution timed out 1566 ms 3932 KB Time limit exceeded
44 Execution timed out 1564 ms 4444 KB Time limit exceeded
45 Execution timed out 1529 ms 4176 KB Time limit exceeded
46 Execution timed out 1531 ms 5200 KB Time limit exceeded
47 Execution timed out 1573 ms 4948 KB Time limit exceeded
48 Execution timed out 1549 ms 5080 KB Time limit exceeded
49 Execution timed out 1519 ms 4952 KB Time limit exceeded
50 Execution timed out 1577 ms 3668 KB Time limit exceeded