#include<stdio.h>
int map[21][21] = {}, win = 0, i, j, c;
int DFS(int y, int x, int se){
if(map[i+y][j+x]!=c)
return se;
if(y>0)
y++;
if(y<0)
y--;
if(x>0)
x++;
if(x<0)
x--;
DFS(y,x,++se);
}
void check(){
int se = 0;
if(map[i-1][j]!=c){
se = DFS(1,0,1);
if(se == 5)
win = 1;
}
if(map[i-1][j-1]!=c){
se = DFS(1,1,1);
if(se == 5)
win = 1;
}
if(map[i][j-1]!=c){
se = DFS(0,1,1);
if(se == 5)
win = 1;
}
if(map[i+1][j-1]!=c){
se = DFS(-1,1,1);
if(se == 5)
win = 1;
}
}
int main(){
for(i = 1 ; i <= 19 ; i++){
for(j = 1 ; j <= 19 ; j++){
scanf("%d",&map[i][j]);
}
}
for(i = 1 ; i <= 19 ; i++){
for(j = 1 ; j <= 19 ; j++){
if(map[i][j] > 0){
c = map[i][j];
check();
if(win == 1){
printf("%d",c);
printf("\n%d %d",i,j);
return 0;
}
}
}
}
printf("0");
return 0;
}
top of page

기능을 테스트하려면 라이브 사이트로 이동하세요.
수정: 2023년 10월 28일
오목
오목
댓글 0개
좋아요
댓글(0)
bottom of page