Submission #523657

# Submission time Handle Problem Language Result Execution time Memory
523657 2022-02-08T03:03:01 Z boykut K blocks (IZhO14_blocks) C++14
0 / 100
0 ms 204 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 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -