# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
38474 | 2018-01-04T09:44:39 Z | alenam0161 | Marriage questions (IZhO14_marriage) | C++14 | 1500 ms | 4008 KB |
#define _CRT_SECURE_NO_WARNINGS #include <iostream> #include <algorithm> #include <vector> #include <cstring> #include <cassert> #include <cstdio> #define ad push_back using namespace std; const int N = 30007; int used[N]; vector<int> g[N]; int ma[N]; int qan = 0; bool try_khun(int v){ if (used[v])return false; used[v] = true; for (int to : g[v]){ if (ma[to] == -1 || try_khun(ma[to])){ //if (ma[to] == -1)qan++; ma[to] = v; return true; } } return false; } int main(){ memset(ma, -1, sizeof(ma)); int n, m, k; scanf("%d%d%d", &n, &m, &k); for (int i = 1; i <= k; ++i){ int u, v; scanf("%d%d", &u, &v); g[u].ad(v); } int l = 1; long long ans = 0; int cnt = 0; for (int i = 1; i <= n; i++) { while (cnt == m) { assert(l <= i); bool minus = false; for (auto x : g[l]) { if (ma[x] == l) { ma[x] = -1; minus = true; break; } } cnt -= minus; l++; } memset(used,0,sizeof(used)); cnt += try_khun(i); if (cnt == m) { ans += n - i + 1; } } cout << ans << endl; return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 2952 KB | Output isn't correct |
2 | Incorrect | 0 ms | 2952 KB | Output isn't correct |
3 | Incorrect | 0 ms | 2952 KB | Output isn't correct |
4 | Incorrect | 0 ms | 2952 KB | Output isn't correct |
5 | Correct | 0 ms | 2952 KB | Output is correct |
6 | Correct | 0 ms | 2952 KB | Output is correct |
7 | Correct | 0 ms | 2952 KB | Output is correct |
8 | Correct | 0 ms | 2952 KB | Output is correct |
9 | Correct | 0 ms | 2952 KB | Output is correct |
10 | Correct | 0 ms | 2952 KB | Output is correct |
11 | Correct | 0 ms | 2952 KB | Output is correct |
12 | Correct | 0 ms | 2952 KB | Output is correct |
13 | Incorrect | 0 ms | 2952 KB | Output isn't correct |
14 | Correct | 0 ms | 2952 KB | Output is correct |
15 | Incorrect | 0 ms | 2952 KB | Output isn't correct |
16 | Incorrect | 0 ms | 2952 KB | Output isn't correct |
17 | Correct | 0 ms | 2952 KB | Output is correct |
18 | Correct | 0 ms | 2952 KB | Output is correct |
19 | Correct | 0 ms | 2952 KB | Output is correct |
20 | Correct | 0 ms | 2952 KB | Output is correct |
21 | Correct | 0 ms | 2952 KB | Output is correct |
22 | Incorrect | 0 ms | 2952 KB | Output isn't correct |
23 | Correct | 0 ms | 2952 KB | Output is correct |
24 | Correct | 0 ms | 2952 KB | Output is correct |
25 | Correct | 6 ms | 3084 KB | Output is correct |
26 | Incorrect | 3 ms | 2952 KB | Output isn't correct |
27 | Correct | 3 ms | 2952 KB | Output is correct |
28 | Incorrect | 3 ms | 2952 KB | Output isn't correct |
29 | Incorrect | 6 ms | 3084 KB | Output isn't correct |
30 | Incorrect | 6 ms | 3084 KB | Output isn't correct |
31 | Correct | 23 ms | 3216 KB | Output is correct |
32 | Incorrect | 16 ms | 3084 KB | Output isn't correct |
33 | Correct | 6 ms | 2952 KB | Output is correct |
34 | Incorrect | 6 ms | 2952 KB | Output isn't correct |
35 | Correct | 89 ms | 3480 KB | Output is correct |
36 | Correct | 73 ms | 3480 KB | Output is correct |
37 | Correct | 59 ms | 3348 KB | Output is correct |
38 | Incorrect | 246 ms | 3744 KB | Output isn't correct |
39 | Incorrect | 86 ms | 3084 KB | Output isn't correct |
40 | Correct | 63 ms | 3216 KB | Output is correct |
41 | Incorrect | 79 ms | 3216 KB | Output isn't correct |
42 | Incorrect | 286 ms | 3348 KB | Output isn't correct |
43 | Incorrect | 383 ms | 3348 KB | Output isn't correct |
44 | Incorrect | 669 ms | 3612 KB | Output isn't correct |
45 | Incorrect | 189 ms | 3612 KB | Output isn't correct |
46 | Execution timed out | 1500 ms | 4008 KB | Execution timed out |
47 | Incorrect | 1426 ms | 3876 KB | Output isn't correct |
48 | Incorrect | 1429 ms | 3876 KB | Output isn't correct |
49 | Execution timed out | 1500 ms | 4008 KB | Execution timed out |
50 | Incorrect | 216 ms | 3084 KB | Output isn't correct |