# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
363281 | 2021-02-05T12:26:22 Z | SamAnd | Marriage questions (IZhO14_marriage) | C++17 | 1500 ms | 2156 KB |
#include <bits/stdc++.h> using namespace std; #define m_p make_pair #define all(x) (x).begin(),(x).end() #define sz(x) ((int)(x).size()) #define fi first #define se second typedef long long ll; mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count()); mt19937 rnf(2106); const int N = 30004, M = 2003; int n, m, k; vector<int> g[M]; int u[N]; int uu[M]; bool c[M]; bool dfs(int x, int l, int r) { if (c[x]) return false; c[x] = true; for (int i = 0; i < g[x].size(); ++i) { int h = g[x][i]; if (!(l <= h && h <= r)) continue; if (u[h] == 0) { u[h] = x; uu[x] = h; return true; } else { if (dfs(u[h], l, r)) { u[h] = x; uu[x] = h; return true; } } } return false; } void solv() { scanf("%d%d%d", &n, &m, &k); for (int i = 0; i < k; ++i) { int x, y; scanf("%d%d", &x, &y); g[y].push_back(x); } int ans = 0; int r = 0; for (int l = 1; l <= n; ++l) { memset(u, 0, sizeof u); memset(uu, 0, sizeof uu); while (1) { ++r; if (r == n + 1) break; int i = 1; while (1) { if (i == m + 1) break; memset(c, false, sizeof c); if (dfs(i, l, r)) { ++i; continue; } break; } if (i == m + 1) break; } if (r == n + 1) break; ans += (n - r + 1); } printf("%d\n", ans); } int main() { #ifdef SOMETHING freopen("input.txt", "r", stdin); //freopen("output.txt", "w", stdout); #endif // SOMETHING //ios_base::sync_with_stdio(false), cin.tie(0); solv(); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 492 KB | Output isn't correct |
2 | Incorrect | 1 ms | 492 KB | Output isn't correct |
3 | Incorrect | 1 ms | 492 KB | Output isn't correct |
4 | Incorrect | 1 ms | 492 KB | Output isn't correct |
5 | Incorrect | 1 ms | 492 KB | Output isn't correct |
6 | Incorrect | 1 ms | 492 KB | Output isn't correct |
7 | Incorrect | 1 ms | 492 KB | Output isn't correct |
8 | Correct | 1 ms | 492 KB | Output is correct |
9 | Correct | 1 ms | 492 KB | Output is correct |
10 | Correct | 1 ms | 492 KB | Output is correct |
11 | Incorrect | 1 ms | 492 KB | Output isn't correct |
12 | Correct | 1 ms | 492 KB | Output is correct |
13 | Incorrect | 1 ms | 492 KB | Output isn't correct |
14 | Incorrect | 1 ms | 492 KB | Output isn't correct |
15 | Incorrect | 1 ms | 492 KB | Output isn't correct |
16 | Incorrect | 1 ms | 492 KB | Output isn't correct |
17 | Incorrect | 1 ms | 492 KB | Output isn't correct |
18 | Incorrect | 1 ms | 492 KB | Output isn't correct |
19 | Incorrect | 1 ms | 492 KB | Output isn't correct |
20 | Incorrect | 1 ms | 492 KB | Output isn't correct |
21 | Correct | 1 ms | 492 KB | Output is correct |
22 | Incorrect | 1 ms | 492 KB | Output isn't correct |
23 | Incorrect | 1 ms | 492 KB | Output isn't correct |
24 | Incorrect | 1 ms | 492 KB | Output isn't correct |
25 | Incorrect | 5 ms | 620 KB | Output isn't correct |
26 | Incorrect | 2 ms | 492 KB | Output isn't correct |
27 | Correct | 1 ms | 492 KB | Output is correct |
28 | Incorrect | 1 ms | 492 KB | Output isn't correct |
29 | Incorrect | 3 ms | 620 KB | Output isn't correct |
30 | Incorrect | 3 ms | 620 KB | Output isn't correct |
31 | Incorrect | 17 ms | 1132 KB | Output isn't correct |
32 | Incorrect | 9 ms | 620 KB | Output isn't correct |
33 | Correct | 1 ms | 492 KB | Output is correct |
34 | Incorrect | 1 ms | 492 KB | Output isn't correct |
35 | Incorrect | 21 ms | 1772 KB | Output isn't correct |
36 | Incorrect | 18 ms | 1644 KB | Output isn't correct |
37 | Incorrect | 29 ms | 1260 KB | Output isn't correct |
38 | Incorrect | 22 ms | 1772 KB | Output isn't correct |
39 | Incorrect | 3 ms | 620 KB | Output isn't correct |
40 | Correct | 4 ms | 748 KB | Output is correct |
41 | Incorrect | 7 ms | 876 KB | Output isn't correct |
42 | Incorrect | 10 ms | 876 KB | Output isn't correct |
43 | Incorrect | 15 ms | 1260 KB | Output isn't correct |
44 | Incorrect | 30 ms | 1900 KB | Output isn't correct |
45 | Execution timed out | 1579 ms | 1004 KB | Time limit exceeded |
46 | Execution timed out | 1583 ms | 2028 KB | Time limit exceeded |
47 | Incorrect | 30 ms | 2028 KB | Output isn't correct |
48 | Incorrect | 27 ms | 1900 KB | Output isn't correct |
49 | Execution timed out | 1574 ms | 2156 KB | Time limit exceeded |
50 | Incorrect | 5 ms | 768 KB | Output isn't correct |