From 52c808140c52119fa945714ac8e230177ce605d6 Mon Sep 17 00:00:00 2001 From: sh0723 Date: Tue, 30 Jun 2026 15:12:53 +0900 Subject: [PATCH] =?UTF-8?q?14890=20:=20=EA=B2=BD=EC=82=AC=EB=A1=9C=20solve?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/week4/BOJ14890/BOJ14890_V1.cpp | 39 ++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 src/week4/BOJ14890/BOJ14890_V1.cpp 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