8000 Merge pull request #55 from cpprhtn/boj-1780 · twinkite/basic-algo-lecture@dcdf533 · GitHub
[go: up one dir, main page]

Skip to content

Commit dcdf533

Browse files
Merge pull request encrypted-def#55 from cpprhtn/boj-1780
Update 1780.cpp
2 parents 6f4ae7f + fbaec2d commit dcdf533

File tree

1 file changed

+33
-5
lines changed

1 file changed

+33
-5
lines changed

0x0B/solutions/1780.cpp

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,39 @@
1-
// Authored by : BaaaaaaaaaaarkingDog
1+
// Authored by : cpprhtn
22
// Co-authored by : -
3-
// http://boj.kr/****************
3+
// http://boj.kr/8882cceb247049b18599a0b2847540b8
44
#include <bits/stdc++.h>
55
using namespace std;
66

7-
int main(void){
7+
int N;
8+
int paper[2200][2200];
9+
int cnt[3]; //-1, 0, 1로 채워진 종이 갯수
10+
11+
//해당 종이 내부에 같은 숫자로만 채워졌는지 확인하는 함수
12+
bool check(int x, int y, int n) {
13+
for (int i = x; i < x + n; i++)
14+
for (int j = y; j < y + n; j++)
15+
if (paper[x][y] != paper[i][j])
16+
return false;
17+
return true;
18+
}
19+
void solve(int x, int y, int z)
20+
{
21+
if (check(x, y, z)) {
22+
cnt[paper[x][y] + 1] += 1;
23+
return;
24+
}
25+
int n = z / 3;
26+
for (int i = 0; i < 3; i++)
27+
for (int j = 0; j < 3; j++)
28+
solve(x + i * n, y + j * n, n);
29+
}
30+
int main(void) {
831
ios::sync_with_stdio(0);
932
cin.tie(0);
10-
11-
}
33+
cin >> N;
34+
for (int i = 0; i < N; i++)
35+
for (int j = 0; j < N; j++)
36+
cin >> paper[i][j];
37+
solve(0, 0, N);
38+
for (int i = 0; i < 3; i++) cout << cnt[i] << "\n";
39+
}

0 commit comments

Comments
 (0)
0