/*#include <stdio.h>
int que[2][2000000]= {},n,m;
int rear=-1,front=-1;
int arr[1001][1001]={};
int px,py;
int cnt=0,a;
void push(int x, int y)
{
if(x<=0 ||y<=0 ||x>n || y>m || arr[x][y]!=0)
return ;
arr[x][y]=2;
rear++;
que[0][rear]=x;
que[1][rear]=y;
}
void pop()
{
front++;
px = que[0][front];
py = que[1][front];
}
//void view()
//{
// printf("----queue------\n");
// for(int i=front+1;i<=rear;i++)
// printf("%d ",que[0][i]);
// printf("\n");
// for(int i=front+1;i<=rear;i++)
// printf("%d ",que[1][i]);
// printf("\n");
// printf("---------------\n");
//}
int main()
{
scanf("%d %d",&m,&n);
for(int i=1;i<=n;i++)
{
for(int j=1;j<=m;j++)
{
scanf("%d",&arr[i][j]);
if(arr[i][j]==1)
{
rear++;
que[0][rear]=i;
que[1][rear]=j;
}
}
}
if(rear==n*m-1) printf("%d",0);
while(rear != front)
{
a =rear;
for(int i=front+1;i<=a;i++)
{
pop();
push(px-1,py);
push(px+1,py);
push(px,py-1);
push(px,py+1);
}
// view();
cnt++;
}
for(int i=1;i<=n;i++)
{
for(int j=1;j<=m;j++)
{
if(arr[i][j]==0)
{
cnt=0;
}
}
}
printf("%d",cnt-1);
return 0;
}
*/
#include <stdio.h>
int que[2][2000000]= {},n;
int rear=-1,front=-1;
int arr[1001][1001]={};
int px,py;
int cnt=0,l;
int a,b,c,d;
int dir[8][2]={+2,+1,+2,-1 ,-2,+1,-2,-1, +1,+2,+1,-2,-1,+2,-1,-2};
void push(int x, int y)
{
if(x<=0 ||y<=0 ||x>n || y>n || arr[x][y]!=0)
return ;
arr[x][y]=2;
rear++;
que[0][rear]=x;
que[1][rear]=y;
}
void pop()
{
front++;
px = que[0][front];
py = que[1][front];
}
void bfs(int i,int j)
{
push(i,j);
while(rear!=front)
{
l=rear;
for(int t=front+1;t<=l;t++)
{
pop();
for(int k=0;k<8;k++){
int xx = px+dir[k][0];
int yy = py+dir[k][1];
push(xx,yy);
if(xx==c&&yy==d) return ;
}
}
// view();
cnt++;
}
}
//void view()
//{
// printf("----queue------\n");
// for(int i=front+1;i<=rear;i++)
// printf("%d ",que[0][i]);
// printf("\n");
// for(int i=front+1;i<=rear;i++)
// printf("%d ",que[1][i]);
// printf("\n");
// printf("---------------\n");
//}
int main()
{
scanf("%d %d %d %d %d",&n,&a,&b,&c,&d);
bfs(a,b);
printf("%d",cnt+1);
return 0;
}
----------------------------------------------------------------------------------파이썬
# print('hello')# a=10# print(a,end=' ')# b="hello"# print(a,a,b,sep='')## print(b*3)## arr = [10,"abcd",0.123]# for i in arr :# print(i)## arr1 = [10,20,30,1,7,1]# print(max(arr1))## print(max(50,100))## c = 'hello world'# print(c[0:3]) # c[0] ~ c[2]## d = c[0:3]+c[2:5]# print(d)## for i in range(10) :# if i%2==0 :# print(i)# print('*')# a = input()# a = int(a)# print(a*3)# a = input()# b = input()a, b = input().split()a=int(a)b=int(b)print(a/b)// 몫% 나머지** 거듭제곱> < >= <= == !=not and orif a%2==0 and i==7 : print('hello')