#include <bits/stdc++.h>
#define fr first
#define sc second
#define OK puts("OK");
#define pb push_back
#define mk make_pair
using namespace std;
typedef long long ll;
const int inf = (int)1e9 + 7;
const int N = (int)1e5 + 7;
int n,m,k;
int x,y;
int a[1001][1001];
int ans;
vector <int> g[N];
bool check (int l,int r) {
if (m == 1) {
for (int i = l; i <= r; i ++)
if (a[i][1])
return 1;
}
else if (m == 2) {
for (int i = l; i <= r; i ++)
for (int j = l; j <= r; j ++)
if (i != j) {
if (a[i][1] && a[j][2])
return 1;
if (a[i][2] && a[j][1])
return 1;
}
}
else if (m == 3) {
for (int i = l; i <= r; i ++)
for (int j = l; j <= r; j ++)
for (int o = l; o <= r; o ++) {
vector <int> v;
if (i != j && o != j && o != i) {
v.pb(1),v.pb(2),v.pb(3);
do {
if (a[i][v[0]] && a[j][v[1]] && a[o][v[2]])
return 1;
}
while(next_permutation(v.begin(),v.end()));
}
}
}
else if (m == 4) {
for (int i = l; i <= r; i ++)
for (int j = l; j <= r; j ++)
for (int o = l; o <= r; o ++)
for (int u = l; u <= r; u ++) {
vector <int> v;
v.pb(1),v.pb(2),v.pb(3),v.pb(4);
if (i != j && o != j && o != i && u != i && u != j && u != o) {
do {
if (a[i][v[0]] && a[j][v[1]] && a[o][v[2]] && a[u][v[3]])
return 1;
}
while(next_permutation(v.begin(),v.end()));
}
}
}
return false;
}
int main () {
cin >> n >> m >> k;
for (int i = 1; i <= k; i ++) {
cin >> x >> y;
a[x][y] = 1;
}
for (int i = 1; i <= n; i ++) {
for (int j = i + m - 1; j <= n; j ++) {
if (check(i,j))
ans ++;
}
}
cout << ans << endl;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
8272 KB |
Output is correct |
2 |
Correct |
0 ms |
8272 KB |
Output is correct |
3 |
Correct |
0 ms |
8272 KB |
Output is correct |
4 |
Correct |
0 ms |
8272 KB |
Output is correct |
5 |
Correct |
3 ms |
8272 KB |
Output is correct |
6 |
Correct |
0 ms |
8272 KB |
Output is correct |
7 |
Incorrect |
0 ms |
8272 KB |
Output isn't correct |
8 |
Correct |
0 ms |
8272 KB |
Output is correct |
9 |
Correct |
0 ms |
8272 KB |
Output is correct |
10 |
Correct |
0 ms |
8272 KB |
Output is correct |
11 |
Correct |
0 ms |
8272 KB |
Output is correct |
12 |
Correct |
0 ms |
8272 KB |
Output is correct |
13 |
Correct |
0 ms |
8272 KB |
Output is correct |
14 |
Incorrect |
0 ms |
8272 KB |
Output isn't correct |
15 |
Incorrect |
0 ms |
8272 KB |
Output isn't correct |
16 |
Incorrect |
0 ms |
8272 KB |
Output isn't correct |
17 |
Incorrect |
0 ms |
8272 KB |
Output isn't correct |
18 |
Incorrect |
0 ms |
8272 KB |
Output isn't correct |
19 |
Incorrect |
3 ms |
8272 KB |
Output isn't correct |
20 |
Incorrect |
3 ms |
8272 KB |
Output isn't correct |
21 |
Correct |
0 ms |
8272 KB |
Output is correct |
22 |
Incorrect |
0 ms |
8272 KB |
Output isn't correct |
23 |
Incorrect |
0 ms |
8272 KB |
Output isn't correct |
24 |
Incorrect |
0 ms |
8272 KB |
Output isn't correct |
25 |
Incorrect |
9 ms |
8272 KB |
Output isn't correct |
26 |
Incorrect |
0 ms |
8272 KB |
Output isn't correct |
27 |
Correct |
3 ms |
8272 KB |
Output is correct |
28 |
Incorrect |
0 ms |
8272 KB |
Output isn't correct |
29 |
Incorrect |
3 ms |
8272 KB |
Output isn't correct |
30 |
Incorrect |
3 ms |
8272 KB |
Output isn't correct |
31 |
Incorrect |
29 ms |
8272 KB |
Output isn't correct |
32 |
Incorrect |
3 ms |
8272 KB |
Output isn't correct |
33 |
Correct |
3 ms |
8272 KB |
Output is correct |
34 |
Incorrect |
3 ms |
8272 KB |
Output isn't correct |
35 |
Incorrect |
53 ms |
8272 KB |
Output isn't correct |
36 |
Incorrect |
49 ms |
8272 KB |
Output isn't correct |
37 |
Runtime error |
0 ms |
8272 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
38 |
Runtime error |
43 ms |
8272 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
39 |
Runtime error |
0 ms |
8272 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
40 |
Runtime error |
0 ms |
8272 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
41 |
Runtime error |
0 ms |
8272 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
42 |
Runtime error |
0 ms |
8272 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
43 |
Runtime error |
0 ms |
8272 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
44 |
Runtime error |
6 ms |
8272 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
45 |
Runtime error |
0 ms |
8272 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
46 |
Runtime error |
0 ms |
8272 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
47 |
Runtime error |
0 ms |
8272 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
48 |
Runtime error |
3 ms |
8272 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
49 |
Runtime error |
0 ms |
8272 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
50 |
Runtime error |
0 ms |
8272 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |