Submission #523660

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

using namespace std;

char dp[2001][30001];
int pref[2001][30001];
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;

	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 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 1 ms 332 KB Output isn't correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Incorrect 1 ms 332 KB Output isn't correct
10 Correct 0 ms 332 KB Output is correct
11 Correct 0 ms 332 KB Output is correct
12 Correct 1 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 1 ms 332 KB Output isn't correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 0 ms 332 KB Output is correct
19 Correct 1 ms 716 KB Output is correct
20 Correct 1 ms 716 KB Output is correct
21 Correct 1 ms 716 KB Output is correct
22 Incorrect 1 ms 716 KB Output isn't correct
23 Correct 1 ms 716 KB Output is correct
24 Correct 1 ms 716 KB Output is correct
25 Correct 3 ms 1292 KB Output is correct
26 Incorrect 2 ms 1356 KB Output isn't correct
27 Correct 1 ms 1356 KB Output is correct
28 Incorrect 1 ms 1228 KB Output isn't correct
29 Correct 2 ms 1356 KB Output is correct
30 Correct 2 ms 1356 KB Output is correct
31 Correct 12 ms 6804 KB Output is correct
32 Incorrect 6 ms 6732 KB Output isn't correct
33 Correct 6 ms 5708 KB Output is correct
34 Incorrect 6 ms 6368 KB Output isn't correct
35 Correct 15 ms 6476 KB Output is correct
36 Correct 14 ms 6440 KB Output is correct
37 Correct 45 ms 20704 KB Output is correct
38 Correct 53 ms 18380 KB Output is correct
39 Incorrect 583 ms 95008 KB Output isn't correct
40 Correct 432 ms 106108 KB Output is correct
41 Correct 603 ms 110488 KB Output is correct
42 Correct 319 ms 67200 KB Output is correct
43 Correct 306 ms 67224 KB Output is correct
44 Correct 703 ms 134148 KB Output is correct
45 Runtime error 255 ms 262148 KB Execution killed with signal 9
46 Runtime error 257 ms 262148 KB Execution killed with signal 9
47 Execution timed out 1551 ms 243404 KB Time limit exceeded
48 Execution timed out 1601 ms 243276 KB Time limit exceeded
49 Runtime error 253 ms 262148 KB Execution killed with signal 9
50 Execution timed out 1594 ms 243208 KB Time limit exceeded