Created
April 27, 2020 15:01
-
-
Save niklasjang/acba7cd79987f58c1484be8087833aca to your computer and use it in GitHub Desktop.
[PS][기출문제][삼성]/[BOJ][14890][경사로]
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
int n, l, ans = 0, i, j, cnt; | |
int map[200][100]; | |
int main(void) { | |
cin >> n >> l; | |
for (i = 0; i < n; i++) | |
for (j = 0; j < n; j++) | |
cin >> map[i][j]; | |
for (i = 0; i < n; i++) | |
for (j = 0; j < n; j++) | |
map[i + n][j] = map[j][i]; | |
for (i = 0; i < n * 2; 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 = -l + 1; | |
else break; | |
} | |
if (j == n - 1 && cnt >= 0) ans++; | |
} | |
printf("%d", ans); | |
return 0; | |
} |
Author
niklasjang
commented
Apr 27, 2020
•
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment