Submission #523658

# Submission time Handle Problem Language Result Execution time Memory
523658 2022-02-08T03:03:21 Z boykut Marriage questions (IZhO14_marriage) C++14
62 / 100
628 ms 262152 KB
#include <bits/stdc++.h>

using namespace std;

vector<vector<char>> dp;
vector<vector<int>> pref;
int n, m, k;
int check(int l, int r) {
	if (r - l + 1 < m) return 0;
	vector<int> mas(m + 1, 0);
	for (int j = 1; j <= m; j++) {
		if (pref[j][r] - pref[j][l-1] > 0)
			mas[j] = 1;
	}
	return (count(mas.begin(), mas.end(), 0) == 1 ? 1 : 0);
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);

	cin >> n >> m >> k;
	dp = vector<vector<char>> (1 + m, vector<char>(1 + n, 0));
	pref = vector<vector<int>> (1 + m, vector<int>(1 + n, 0));

	for (int i = 0; i < k; i++) {
		int a, b;
		cin >> a >> b;
		dp[b][a] = 1;
	}

	for (int j = 1; j <= m; j++) {
		for (int i = 1; i <= n; i++) {
			pref[j][i] = pref[j][i-1] + dp[j][i];
		}
	}

	long long ans = 0;
	for (int l = 1, r = 1; l <= n; l++) {
		while (r <= n && !check(l, r)) r++;
		if (r <= n) {
			ans += n - r + 1;
		}
	}
	cout << ans << '\n';

	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Incorrect 1 ms 204 KB Output isn't correct
3 Incorrect 1 ms 204 KB Output isn't correct
4 Incorrect 1 ms 204 KB Output isn't correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Incorrect 0 ms 204 KB Output isn't correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Incorrect 0 ms 204 KB Output isn't correct
15 Incorrect 0 ms 204 KB Output isn't correct
16 Incorrect 0 ms 204 KB Output isn't correct
17 Correct 0 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 332 KB Output is correct
20 Correct 1 ms 332 KB Output is correct
21 Correct 1 ms 332 KB Output is correct
22 Incorrect 0 ms 332 KB Output isn't correct
23 Correct 1 ms 332 KB Output is correct
24 Correct 1 ms 332 KB Output is correct
25 Correct 2 ms 460 KB Output is correct
26 Incorrect 1 ms 460 KB Output isn't correct
27 Correct 1 ms 488 KB Output is correct
28 Incorrect 1 ms 460 KB Output isn't correct
29 Correct 2 ms 460 KB Output is correct
30 Correct 1 ms 460 KB Output is correct
31 Correct 9 ms 2764 KB Output is correct
32 Incorrect 4 ms 2764 KB Output isn't correct
33 Correct 3 ms 2764 KB Output is correct
34 Incorrect 4 ms 2764 KB Output isn't correct
35 Correct 20 ms 2764 KB Output is correct
36 Correct 13 ms 2764 KB Output is correct
37 Correct 40 ms 12620 KB Output is correct
38 Correct 44 ms 12564 KB Output is correct
39 Incorrect 497 ms 98408 KB Output isn't correct
40 Correct 364 ms 98396 KB Output is correct
41 Correct 483 ms 98400 KB Output is correct
42 Correct 298 ms 73924 KB Output is correct
43 Correct 275 ms 73908 KB Output is correct
44 Correct 628 ms 147380 KB Output is correct
45 Runtime error 101 ms 262148 KB Execution killed with signal 9
46 Runtime error 109 ms 262148 KB Execution killed with signal 9
47 Runtime error 99 ms 262148 KB Execution killed with signal 9
48 Runtime error 135 ms 262152 KB Execution killed with signal 9
49 Runtime error 99 ms 262148 KB Execution killed with signal 9
50 Runtime error 101 ms 262148 KB Execution killed with signal 9