Muscardinus
경사로 본문
728x90
https://www.acmicpc.net/problem/14890
#include <iostream>
using namespace std;
int n, l;
int map[200][200];
int answer = 0;
int main() {
ios_base::sync_with_stdio(false);
cin >> n >> l;
for (int y = 0; y < n; y++) {
for (int x = 0; x < n; x++) {
cin >> map[y][x];
}
}
for (int y = 0; y < n; y++) {
for (int x = 0; x < n; x++) {
map[y + n][x] = map[x][y];
}
}
int i, j;
int cnt;
for (i = 0; i < 2 * n; i++) {
cnt = 1;
for (j = 0; j < n - 1; j++) {
if (map[i][j] == map[i][j + 1]) cnt++;
else if (map[i][j] + 1 == map[i][j + 1] && cnt >= l) {
cnt = 1;
}
else if (map[i][j] - 1 == map[i][j + 1] && cnt >= 0) {
cnt = 1 - l;
}
else break;
}
if (j == n - 1 && cnt >= 0) answer++;
}
cout << answer << "\n";
return 0;
}
728x90
Comments