[문제 링크] : https://www.acmicpc.net/problem/1030
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
int S, N, K, Y1, X1, Y2, X2;
bool Arr[51][51];
void solve(int s, int y, int x){
if(s == 1){
return;
}
if(y > Y2 || y + s -1 < Y1 || x > X2 || x + s - 1 < X1){
return;
}
int start = s / N * (N - K) / 2;
int end = start + s / N * K - 1;
int y1 = max(Y1, start + y);
int x1 = max(X1, start + x);
int y2 = min(Y2, end + y);
int x2 = min(X2, end + x);
for(int i=y1; i<=y2; i++){
for(int j=x1; j<=x2; j++){
Arr[i-Y1][j-X1] = true;
}
}
for(int i=0; i<s; i+=s/N){
for(int j=0; j<s; j+=s/N){
if(i >= start && i <= start && j >= start && j <= end){
continue;
}
solve(s / N, y + i, x + j);
}
}
return;
}
int main(){
cin >> S >> N >> K >> Y1 >> Y2 >> X1 >> X2;
solve((int)pow(N, S), 0, 0);
for(int i=0; i<Y2-Y1+1; i++){
for(int j=0; j<X2-X1+1; j++){
if(Arr[i][j] == true){
cout << 1;
}
else{
cout << 0;
}
}
cout << "\n";
}
return 0;
}
'알고리즘' 카테고리의 다른 글
[알고리즘] 백준 6378 - 디지털 루트 (C++) (0) | 2025.01.01 |
---|---|
[알고리즘] 백준 17356 - 욱 제 (C++) (0) | 2024.12.31 |
[알고리즘] 백준 20053 - 최소, 최대 2 (C++) (0) | 2024.12.29 |
[알고리즘] 백준 13410 - 거꾸로 구구단 (C++) (0) | 2024.12.28 |
[알고리즘] 백준 14487 - 욱제는 효도쟁이야!! (C++) (0) | 2024.12.27 |