20250719
//숫자 등고선_BFS (진행중)
#include <stdio.h>
#include <string.h>
int s, r=0;
int a[101][101]={};
int queue[10001][2]={};
int front=-1, back=-1;
int px, py;
int c=1;
void push(int h, int r)
{
if(h<1 || h>s || r<1 || r>s || a[h][r]!=0)
return;
back++;
queue[back][0]=h;
queue[back][1]=r;
a[h][r] = c;
}
void pop()
{
if(back==front){
return ;
}
front++;
px = queue[front][0];
py = queue[front][1];
}
void bfs(int x, int y)
{
int index;
push(x, y);
index = back;
while(front!=back){
if(index==front+1){
c++;
r=1;
}
pop();
push(px-1, py);
push(px, py-1);
push(px+1, py);
push(px, py+1);
if(r==1){
index = back;
r=0;
}
}
}
int main()
{
int x, y, i, j;
scanf("%d", &s);
scanf("%d %d", &x, &y);
bfs(x, y);
for(i=1; i<=s; i++){
for(j=1; j<=s; j++){
printf("%2d ", a[i][j]);
}
printf("\n");
}
return 0;
}
//체스 말 이동
/*
#include <stdio.h>
int main()
{
return 0;
}
*/
//토마토_BFS
/*
#include <stdio.h>
int main()
{
return 0;
}
*/




