Submission #523664

# Submission time Handle Problem Language Result Execution time Memory
523664 2022-02-08T03:14:56 Z boykut Marriage questions (IZhO14_marriage) C++14
68 / 100
1500 ms 235236 KB
#include <bits/stdc++.h>

using namespace std;

//char dp[2222][33333];
int pref[2002][30003];
int n, m, k;

int check(int l, int r) {
	if (r - l + 1 < m) return 0;
	for (int j = 1; j <= m; j++) {
		if (pref[j][r] - pref[j][l-1] == 0)
			return 0;
	}
	return 1;
}

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

	cin >> n >> m >> k;

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

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

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

	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Incorrect 1 ms 332 KB Output isn't correct
3 Incorrect 0 ms 332 KB Output isn't correct
4 Incorrect 0 ms 332 KB Output isn't correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 0 ms 332 KB Output is correct
7 Correct 0 ms 332 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Incorrect 0 ms 332 KB Output isn't correct
10 Correct 0 ms 332 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 0 ms 332 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Incorrect 0 ms 332 KB Output isn't correct
15 Incorrect 1 ms 332 KB Output isn't correct
16 Incorrect 0 ms 332 KB Output isn't correct
17 Correct 0 ms 332 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 1 ms 460 KB Output is correct
20 Correct 1 ms 460 KB Output is correct
21 Correct 1 ms 460 KB Output is correct
22 Incorrect 1 ms 460 KB Output isn't correct
23 Correct 1 ms 460 KB Output is correct
24 Correct 0 ms 460 KB Output is correct
25 Correct 2 ms 844 KB Output is correct
26 Incorrect 1 ms 844 KB Output isn't correct
27 Correct 1 ms 844 KB Output is correct
28 Incorrect 1 ms 844 KB Output isn't correct
29 Correct 2 ms 844 KB Output is correct
30 Correct 1 ms 844 KB Output is correct
31 Correct 10 ms 4336 KB Output is correct
32 Incorrect 4 ms 4380 KB Output isn't correct
33 Correct 3 ms 4300 KB Output is correct
34 Incorrect 4 ms 4300 KB Output isn't correct
35 Correct 18 ms 4332 KB Output is correct
36 Correct 12 ms 4300 KB Output is correct
37 Correct 45 ms 14288 KB Output is correct
38 Correct 31 ms 14276 KB Output is correct
39 Incorrect 276 ms 86792 KB Output isn't correct
40 Correct 81 ms 86852 KB Output is correct
41 Correct 281 ms 86864 KB Output is correct
42 Correct 141 ms 63096 KB Output is correct
43 Correct 132 ms 63040 KB Output is correct
44 Correct 363 ms 125956 KB Output is correct
45 Correct 1181 ms 235156 KB Output is correct
46 Execution timed out 1599 ms 235148 KB Time limit exceeded
47 Correct 729 ms 235076 KB Output is correct
48 Correct 705 ms 235160 KB Output is correct
49 Execution timed out 1580 ms 235156 KB Time limit exceeded
50 Incorrect 864 ms 235236 KB Output isn't correct