반응형
temp = []
for _ in range(5):
  temp.append(list(map(int,input().split())))

bingo = []
for __ in range(5):
  bingo.append(list(map(int,input().split())))

def bingo_check(temp):
  bingo_count=0
  for line in temp:
    if sum(line) == 0:
      bingo_count +=1

  for i in range(5):
    if temp[0][i]+temp[1][i]+temp[2][i]+temp[3][i]+temp[4][i] ==0:
      bingo_count+=1
  
  if temp[4][0]+temp[3][1]+temp[2][2]+temp[1][3]+temp[0][4] ==0:
    bingo_count+=1
  
  if temp[0][0]+temp[1][1]+temp[2][2]+temp[3][3]+temp[4][4] ==0:
    bingo_count +=1
  
  return bingo_count


def answer_check(bingo, temp):
  answer=0
  for order in bingo:
    for num in order:
      answer+=1
      for i in range(5):
        for j in range(5):
          if temp[i][j] == num:
            temp[i][j] = 0
            if bingo_check(temp)>=3:
              return(answer)

print(answer_check(bingo, temp))
반응형

+ Recent posts