diff --git a/src/week4/BOJ14890/BOJ14890_V1.cpp b/src/week4/BOJ14890/BOJ14890_V1.cpp new file mode 100644 index 0000000..965c2a2 --- /dev/null +++ b/src/week4/BOJ14890/BOJ14890_V1.cpp @@ -0,0 +1,39 @@ +#include +using namespace std; +int n,m; +int ret; +void calculate(int arr[101][101]) { + for (int i=0; i= m) cnt = 1; + else if (arr[i][j] - 1 == arr[i][j+1] && cnt >= 0) cnt = -(m-1); + else break; + } + if (j == n-1 && cnt >= 0) ret++; + } +} +int main() { + ios::sync_with_stdio(false); + cin.tie(NULL); + cout.tie(NULL); + + cin >> n >> m; + int a[101][101], b[101][101]; + + for (int i = 0; i < n; i++) { + for (int j = 0; j < n; j++) { + cin >> a[i][j]; + b[j][i] = a[i][j]; + } + } + + calculate(a); + calculate(b); + + cout << ret << '\n'; + + return 0; +} \ No newline at end of file