#include <bits/stdc++.h>
using namespace std;
vector<vector<char>> dp;
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++) {
for (int i = l; i <= r; i++) {
mas[j] |= dp[j][i];
}
}
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));
for (int i = 0; i < k; i++) {
int a, b;
cin >> a >> b;
dp[b][a] = 1;
}
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;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Incorrect |
0 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 |
208 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
0 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 |
0 ms |
204 KB |
Output is correct |
12 |
Correct |
0 ms |
204 KB |
Output is correct |
13 |
Correct |
0 ms |
204 KB |
Output is correct |
14 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
15 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
16 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
17 |
Correct |
1 ms |
204 KB |
Output is correct |
18 |
Correct |
0 ms |
204 KB |
Output is correct |
19 |
Correct |
1 ms |
204 KB |
Output is correct |
20 |
Correct |
1 ms |
204 KB |
Output is correct |
21 |
Correct |
1 ms |
204 KB |
Output is correct |
22 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
23 |
Correct |
1 ms |
320 KB |
Output is correct |
24 |
Correct |
1 ms |
204 KB |
Output is correct |
25 |
Correct |
6 ms |
332 KB |
Output is correct |
26 |
Incorrect |
8 ms |
360 KB |
Output isn't correct |
27 |
Correct |
8 ms |
332 KB |
Output is correct |
28 |
Incorrect |
9 ms |
364 KB |
Output isn't correct |
29 |
Correct |
12 ms |
360 KB |
Output is correct |
30 |
Correct |
15 ms |
364 KB |
Output is correct |
31 |
Correct |
93 ms |
824 KB |
Output is correct |
32 |
Incorrect |
148 ms |
808 KB |
Output isn't correct |
33 |
Correct |
120 ms |
716 KB |
Output is correct |
34 |
Incorrect |
150 ms |
716 KB |
Output isn't correct |
35 |
Correct |
109 ms |
716 KB |
Output is correct |
36 |
Correct |
107 ms |
716 KB |
Output is correct |
37 |
Correct |
970 ms |
2792 KB |
Output is correct |
38 |
Execution timed out |
1584 ms |
2764 KB |
Time limit exceeded |
39 |
Execution timed out |
1592 ms |
19904 KB |
Time limit exceeded |
40 |
Execution timed out |
1581 ms |
19916 KB |
Time limit exceeded |
41 |
Execution timed out |
1575 ms |
19916 KB |
Time limit exceeded |
42 |
Execution timed out |
1572 ms |
15052 KB |
Time limit exceeded |
43 |
Execution timed out |
1591 ms |
15052 KB |
Time limit exceeded |
44 |
Execution timed out |
1573 ms |
29748 KB |
Time limit exceeded |
45 |
Execution timed out |
1563 ms |
59084 KB |
Time limit exceeded |
46 |
Execution timed out |
1585 ms |
59108 KB |
Time limit exceeded |
47 |
Execution timed out |
1598 ms |
59084 KB |
Time limit exceeded |
48 |
Execution timed out |
1566 ms |
59084 KB |
Time limit exceeded |
49 |
Execution timed out |
1595 ms |
59132 KB |
Time limit exceeded |
50 |
Execution timed out |
1581 ms |
59084 KB |
Time limit exceeded |