More actions
No edit summary |
(Repair pages found by live-compare batch 0001) |
||
| Line 13: | Line 13: | ||
int N; | int N; | ||
int arr | int arr[129][129] = { 0, }; | ||
int ans | int ans[2] = { 0, }; | ||
void search(int x, int y, int num){ | void search(int x, int y, int num){ | ||
//cout<< x << " " << y << " " << num << endl; | //cout<< x << " " << y << " " << num << endl; | ||
if(num == 1){ | if(num == 1){ | ||
ans | ans[arr[x][y]]++; | ||
return; | return; | ||
} | } | ||
int allSame = true; | int allSame = true; | ||
int color = arr | int color = arr[x][y]; | ||
for(int i = 0; i<num && allSame; i++){ | for(int i = 0; i<num && allSame; i++){ | ||
for(int j = 0; j<num && allSame; j++){ | for(int j = 0; j<num && allSame; j++){ | ||
if(arr | if(arr[x+i][y+j] != color){ | ||
allSame = false; | allSame = false; | ||
} | } | ||
| Line 32: | Line 32: | ||
} | } | ||
if(allSame){ | if(allSame){ | ||
ans | ans[color]++; | ||
return; | return; | ||
} | } | ||
| Line 46: | Line 46: | ||
for(int i = 0; i<N; i++){ | for(int i = 0; i<N; i++){ | ||
for(int j = 0; j<N; j++){ | for(int j = 0; j<N; j++){ | ||
cin>> arr | cin>> arr[i][j]; | ||
} | } | ||
} | } | ||
search(0,0, N); | search(0,0, N); | ||
cout<< ans | cout<< ans[0] << endl << ans[1] <<endl; | ||
} | } | ||
== 박인서 == | == 박인서 == | ||
#include <iostream> | #include <iostream> | ||
int a | int a[130][130]; | ||
int cnt | int cnt[2]; | ||
void divcon(int x1, int x2, int y1, int y2) { | void divcon(int x1, int x2, int y1, int y2) { | ||
int col = a | int col = a[x1][y1]; | ||
bool flag = false; | bool flag = false; | ||
for (int i = x1; i < x2; i++) { | for (int i = x1; i < x2; i++) { | ||
for (int j = y1; j < y2; j++) { | for (int j = y1; j < y2; j++) { | ||
if (a | if (a[i][j] != col) { | ||
flag = true; | flag = true; | ||
break; | break; | ||
| Line 78: | Line 78: | ||
divcon(xm, x2, ym, y2); | divcon(xm, x2, ym, y2); | ||
} | } | ||
else cnt | else cnt[col]++; | ||
} | } | ||
| Line 87: | Line 87: | ||
for (int i = 0; i < n; i++) { | for (int i = 0; i < n; i++) { | ||
for (int j = 0; j < n; j++) | for (int j = 0; j < n; j++) | ||
std::cin >> a | std::cin >> a[i][j]; | ||
} | } | ||
divcon(0, n, 0, n); | divcon(0, n, 0, n); | ||
std::cout << cnt | std::cout << cnt[0] << std::endl << cnt[1]; | ||
return 0; | return 0; | ||
} | } | ||
| Line 105: | Line 105: | ||
== 곽정흠 == | == 곽정흠 == | ||
Latest revision as of 14:46, 26 March 2026
오늘의 문제
참가자
- 박인서
코드
15이원준
#include<iostream>
using namespace std;
int N;
int arr[129][129] = { 0, };
int ans[2] = { 0, };
void search(int x, int y, int num){
//cout<< x << " " << y << " " << num << endl;
if(num == 1){
ans[arr[x][y]]++;
return;
}
int allSame = true;
int color = arr[x][y];
for(int i = 0; i<num && allSame; i++){
for(int j = 0; j<num && allSame; j++){
if(arr[x+i][y+j] != color){
allSame = false;
}
}
}
if(allSame){
ans[color]++;
return;
}
search(x, y, num/2);
search(x+(num/2), y, num/2);
search(x, y+(num/2), num/2);
search(x+(num/2), y+(num/2), num/2);
}
int main(){
cin>> N;
for(int i = 0; i<N; i++){
for(int j = 0; j<N; j++){
cin>> arr[i][j];
}
}
search(0,0, N);
cout<< ans[0] << endl << ans[1] <<endl;
}
박인서
#include <iostream>
int a[130][130];
int cnt[2];
void divcon(int x1, int x2, int y1, int y2) {
int col = a[x1][y1];
bool flag = false;
for (int i = x1; i < x2; i++) {
for (int j = y1; j < y2; j++) {
if (a[i][j] != col) {
flag = true;
break;
}
}
if (flag) break;
}
if (flag) {
int xm = (x1 + x2) / 2, ym = (y1 + y2) / 2;
divcon(x1, xm, y1, ym);
divcon(x1, xm, ym, y2);
divcon(xm, x2, y1, ym);
divcon(xm, x2, ym, y2);
}
else cnt[col]++;
}
int main()
{
int n;
std::cin >> n;
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++)
std::cin >> a[i][j];
}
divcon(0, n, 0, n);
std::cout << cnt[0] << std::endl << cnt[1];
return 0;
}
곽정흠
아이디어
15이원준
박인서
- 색종이의 전체를 비교한 뒤에 안되면 중앙을 기준으로 4개의 색종이로 분해
- 계속해서 찾아나간 뒤 색이 같으면 그 색의 색종이 갯수를 증가시켜주면 된다.