top of page

소스 코드 제출

공개·회원 80명

import sys

sys.setrecursionlimit(10000000)

def dfs(x,y,k,dir):

global c,n,h

#k 몇번째돌인지

if k==5 and dir==0 and n[x-6][y]!=c : # 돌6개때문에!!

h+=1

return

if k==5 and dir==1 and n[x-6][y-6]!=c:

h+=1

return

if k==5 and dir==2 and n[x][y-6]!=c:

h+=1

return

if k==5 and dir==3 and n[x+6][y-6]!=c:

h+=1

return


if dir==0 :

if n[x+1][y]==c :

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

elif dir==1 :

if n[x+1][y+1]==c:

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

elif dir==2 :

if n[x][y+1]==c:

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

elif dir==3 :

if n[x-1][y+1]==c:

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


n=[]

c=0 # 말 1인지 2인지

h=0 # 5개되었는지확인

s=[0]*21

n.append(s)

for i in range(19):

l=list(map(int, input().split()))

l.append(0)

l.insert(0,0)

n.append(l)

n.append(s)

m=[]

for i in range(1,20):

for j in range(1,20):

if n[i][j]!=0:

c=n[i][j]

for u in range(4) :

dfs(i,j,1,u)

if h==1 :

print(c)

print(i, j)

exit(0) # 프로그램종료


print('0')

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