top of page

소스 코드 제출

공개·회원 50명

2025.05,21

#include <stdio.h>

int arr[22][22]={},cnt=0,win=0,num;

void dfs(int x,int y,int k)

{

if(x==-1||y==-1||x==19||y==19||arr[x][y]!=num)

{

return ;

}

else

{

cnt++;

}

if(k==1)

{

dfs(x-1,y+1,k);

}

else if(k==2)

{

dfs(x,y+1,k);

}

else if(k==3)

{

dfs(x+1,y+1,k);

}

else if(k==4)

{

dfs(x+1,y,k);

}

return ;

}

int main()

{

int i,j;

for(i=0;i<19;i++)

{

for(j=0;j<19;j++)

{

scanf("%d",&arr[i][j]);

}

}

for(j=0;j<19;j++)

{

for(i=0;i<19;i++)

{

if(arr[i][j]!=0)

{

for(int k=1;k<=4;k++)

{

num=arr[i][j];

dfs(i,j,k);

if(cnt==5)

{

printf("%d\n%d %d",num,i+1,j+1);

win=1;

}

cnt=0;

}

}

}

}

if(win==0)

{

printf("0");

}

}

2회 조회
주소 : 경기도 용인시 광교중앙로 302 블루 스퀘어 602호
연락처 : 031) 216 - 1546 ,     031) 215 - 1546
사업자등록번호 : 465-92-00916
​학원 등록 제 4603호
bottom of page