Untitled
unknown
plain_text
a year ago
1.7 kB
8
Indexable
#include <iostream>
#include <vector>
using namespace std;
int n, map[20][20];
void init(int N, int mMap[20][20]) {
v.clear();
re_v.clear();
}
int numberOfCandidate(int M, int mStructure[5]) {
if (M == 1) return n * n;
vector<int> v(mStructure, mStructure + M);
vector<int> re_v(mStructure + M - 1, mStructure - 1);
int cnt = 0;
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
bool check_hozion = true, check_vertical = true;
for (int k = 0; k < M - 1 && (check_hozion || check_vertical); k++) {
if (j + M - 1 < n) {
if (map[i][j + k] + v[k] != map[i][j + k + 1] + v[k + 1] &&
map[i][j + k] + re_v[k] != map[i][j + k + 1] + re_v[k + 1]) {
check_hozion = false;
}
} else {
check_hozion = false;
}
if (i + M - 1 < n) {
if (map[i + k][j] + v[k] != map[i + k + 1][j] + v[k + 1] &&
map[i + k][j] + re_v[k] != map[i + k + 1][j] + re_v[k + 1]) {
check_vertical = false;
}
} else {
check_vertical = false;
}
}
if (check_hozion) cnt++;
if (check_vertical) cnt++;
}
}
return cnt;
}
int main() {
freopen("sample_input.txt", "r", stdin);
cin >> n;
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
cin >> map[i][j];
}
}
init(6, map);
int mStructure[3] = {1, 1, 1};
cout << numberOfCandidate(3, mStructure);
return 0;
}
Editor is loading...
Leave a Comment