Problem:


Score : 200 points

Problem Statement

We have a bingo card with a 3\times3 grid. The square at the i-th row from the top and the j-th column from the left contains the number A_{i, j}.

The MC will choose N numbers, b_1, b_2, \cdots, b_N. If our bingo sheet contains some of those numbers, we will mark them on our sheet.

Determine whether we will have a bingo when the N numbers are chosen, that is, the sheet will contain three marked numbers in a row, column, or diagonal.

Constraints

All values in input are integers.

1 \leq A_{i, j} \leq 100

A_{i_1, j_1} \neq A_{i_2, j_2} ((i_1, j_1) \neq (i_2, j_2))

1 \leq N \leq 10

1 \leq b_i \leq 100

b_i \neq b_j (i \neq j)

Input

Input is given from Standard Input in the following format:

A_{1, 1} A_{1, 2} A_{1, 3}
A_{2, 1} A_{2, 2} A_{2, 3}
A_{3, 1} A_{3, 2} A_{3, 3}
N
b_1
\vdots
b_N

Output

If we will have a bingo, print Yes; otherwise, print No.

Sample Input 1

84 97 66
79 89 11
61 59 7
7
89
7
87
79
24
84
30

Sample Output 1

Yes

We will mark A_{1, 1}, A_{2, 1}, A_{2, 2}, A_{3, 3}, and complete the diagonal from the top-left to the bottom-right.

Sample Input 2

41 7 46
26 89 2
78 92 8
5
6
45
16
57
17

Sample Output 2

No

We will mark nothing.

Sample Input 3

60 88 34
92 41 43
65 73 48
10
60
43
88
11
48
73
65
41
92
34

Sample Output 3

Yes

We will mark all the squares.



Sample input:
84 97 66
79 89 11
61 59 7
7
89
7
87
79
24
84
30


Sample output:
Yes

Submission status: Wrong Answer

Solution code:
a = input()
b = input()
c = input()
list_ans =(a,b,c)
N = int(input())
bingo_list=[]

for i in range(N):
    bingo = input()
    bingo_list.append(bingo)
    
    
print(bingo_list)
#横ビンゴ判定
def bingo_row(p,q):
    #p 横のリスト　q 出た値のリスト
    for i in range(3):
        if p[i] in q:
            return True
        else:
            return False
#縦ビンゴ判定
def bingo_column(p,q,r,s):
    #pqr横リスト　s bingo_list
    for i in range(3):
        if p[i]  in s and q[i] in s:
            if r[i] in s:
                return True
            else:
                return False
        else:
            return False
#斜めビンゴ判定
def bingo_slash(p,q,r,s):
    if q[1] in s:
        if p[0] in s and r[2] in s:
            return True
        elif p[2] in s and r[0] in s:
            return True
        else:
            return False
    else:
        return False
print(bingo_row(a,bingo_list))
    
total = 0
for i in list_ans:
    if bingo_row(i, bingo_list):
        print('Yes')
        break
    elif bingo_column(a,b,c,bingo_list):
        print('Yes')
        break
    elif bingo_slash(a,b,c,bingo_list):
        print('Yes')
        break
    else:
        total += 1
if total == 3:
    print('No')

Submission status: Wrong Answer

Solution code:
a = input()
b = input()
c = input()
list_ans =(a,b,c)
N = int(input())


for i in range(N):
    bingo = input()
    bingo_list=[]
    bingo_list.append(bingo)
    
    
    
#横ビンゴ判定
def bingo_row(p,q):
    #p 横のリスト　q 出た値のリスト
    if p in q:
        return True
    else:
        return False
#縦ビンゴ判定
def bingo_column(p,q,r,s):
    #pqr横リスト　s bingo_list
    for i in range(3):
        if p[i]  in s and q[i] in s:
            if r[i] in s:
                return True
            else:
                return False
        else:
            return False
#斜めビンゴ判定
def bingo_slash(p,q,r,s):
    if q[1] in s:
        if p[0] in s and r[2]:
            return True
        elif p[2] in s and r[0]:
            return True
        else:
            return False
    else:
        return False
    
total = 0
for i in list_ans:
    if bingo_row(i, bingo_list):
        print('Yes')
        break
    elif bingo_column(a,b,c,bingo_list):
        print('Yes')
        break
    elif bingo_slash(a,b,c,bingo_list):
        print('Yes')
        break
    else:
        total += 1
if total == 3:
    print('No')

Submission status: Wrong Answer

Solution code:
class Bingo:
    def check_num(self, arr, B):
        for b in B:
            for y in range(3):
                for x in range(3):
                    if arr[y][x] == b:
                        arr[y][x] = -1
        return arr
    def check_bingo(self, arr):
        for y in range(3):
            f = True
            for x in range(3):
                if arr[y][x] != -1:
                    f = False
        if f:
            print("Yes")
            exit()
        for x in range(3):
            f = True
            for y in range(3):
                if arr[y][x] != -1:
                    f = False
        if f:
            print("Yes")
            exit()
        for y in range(3):
            f = True
            for y in range(3):
                if arr[y][y] != -1:
                    f = False
        if f:
            print("Yes")
            exit()
        for x in range(3):
            f = True
            for x in range(3):
                if arr[x][x] != -1:
                    f = False
        if f:
            print("Yes")
            exit()
        print('No')

if __name__ == "__main__":
    A1 = list(map(int, input().split())) 
    A2 = list(map(int, input().split())) 
    A3 = list(map(int, input().split())) 
    arr = [A1, A2, A3]
    N = int(input())
    B = [int(input()) for _ in range(N)]
    b = Bingo()
    result_list = b.check_num(arr, B)
    b.check_bingo(result_list)

Submission status: Wrong Answer

Solution code:
import sys
list1=[]
list3=["Bingo","Bingo","Bingo"]
A1,A2,A3=map(str,input().split())
A4,A5,A6=map(str,input().split())
A7,A8,A9=map(str,input().split())
n=int(input())
list1=[input() for i in range(1,n+1)]
list2=[[A1,A2,A3],
    [A4,A5,A6],
    [A7,A8,A9]]
for y in range(3):
    for x in range(n):
            if (list1[x] in list2[y])==True:
                s=list2[y].index(list1[x])
                list2[y][s]="Bingo"
#横
for i in range(3):
    if list2[i]==list3:
        print("Yes")
        sys.exit()
#斜め
if list2[0][0]==list2[1][1] and list2[1][1]==list2[2][2]:
    print("Yes")
elif list2[0][2]==list2[1][1] and list2[1][1]==list2[2][0]:
    print("Yes")
#縦
for z in range(3):
    if list2[z][0]==list3:
        print("Yes")
for g in range(3):
    if list2[g][1]==list3:
        print("Yes")
for h in range(3):
    if list2[h][2]==list3:
        prin("Yes")
if n<=2:
    print("No")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
a = [list(map(int, input().split())) for _ in range(3)]
n = int(input())
b = [int(input()) for _ in range(n)]
bingo = [[0 for _ in range(3)] for _ in range(3)]
print(bingo)
for i in range(n):
    for j in range(3):
        for k in range(3):
            if a[j][k] == b[i]:
                bingo[j][k] = True
if (bingo[0][0] and bingo[1][0] and bingo[2][0]) or (bingo[0][1] and bingo[1][1] and bingo[2][1]) or (bingo[0][2] and bingo[1][2] and bingo[2][2]):
    print('Yes')
elif (bingo[0][0] and bingo[0][1] and bingo[0][2]) or (bingo[1][0] and bingo[1][1] and bingo[1][2]) or (bingo[2][0] and bingo[2][1] and bingo[2][2]):
    print('Yes')
elif (bingo[0][0] and bingo[1][1] and bingo[2][2]) or (bingo[0][2] and bingo[1][1] and bingo[2][0]):
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
list1=[]
A1,A2,A3=map(str,input().split())
A4,A5,A6=map(str,input().split())
A7,A8,A9=map(str,input().split())
n=int(input())
list1=[input() for i in range(1,n+1)]
list2=[A1,A2,A3,
    A4,A5,A6,
    A7,A8,A9]
for x in range(n):
    if (list1[x] in list2)==True:
        list2[list2.index(list1[x])]="Bingo"
if n<=2:
    print("No")
elif list2[0]==list2[1] and list2[1]==list2[2]:
    print("Yes")
elif list2[0]==list2[3] and list2[3]==list2[6]:
    print("Yes")
elif list2[3]==list2[4] and list2[4]==list2[5]:
    print("Yes")
elif list2[6]==list2[7] and list2[4]==list2[8]:
    print("Yes")
elif list2[1]==list2[4] and list2[4]==list2[7]:
    print("Yes")
elif list2[2]==list2[5] and list2[5]==list2[8]:
    print("Yes")
elif list2[0]==list2[4] and list2[4]==list2[8]:
    print("Yes")
elif list2[2]==list2[4] and list2[4]==list2[6]:
    print("Yes")
else:print("No")

Submission status: Wrong Answer

Solution code:
list1=[]
A1,A2,A3=map(str,input().split())
A4,A5,A6=map(str,input().split())
A7,A8,A9=map(str,input().split())
n=int(input())
list1=[input() for i in range(1,n+1)]
list2=[A1,A2,A3,
    A4,A5,A6,
    A7,A8,A9]
for x in range(n):
    if (list1[x] in list2)==True:
        list2[list2.index(list1[x])]="Bingo"

if list2[0]==list2[1] and list2[1]==list2[2]:
    print("Yes")
elif list2[0]==list2[3] and list2[3]==list2[6]:
    print("Yes")
elif list2[3]==list2[4] and list2[4]==list2[5]:
    print("Yes")
elif list2[6]==list2[7] and list2[4]==list2[8]:
    print("Yes")
elif list2[1]==list2[4] and list2[4]==list2[7]:
    print("Yes")
elif list2[2]==list2[5] and list2[5]==list2[8]:
    print("Yes")
elif list2[0]==list2[4] and list2[4]==list2[8]:
    print("Yes")
elif list2[2]==list2[4] and list2[4]==list2[6]:
    print("Yes")
else:print("No")

Submission status: Wrong Answer

Solution code:
a = [list(map(int, input().split())) for _ in range(3)]
n = int(input())
b = [int(input()) for _ in range(n)]
bingo = [[False]*3]*3
for i in range(n):
    index = [[x, y] for y, row in enumerate(a) for x, elem in enumerate(row) if a[x][y] == b[i]]
    for j in range(len(index)):
        bingo[index[j][0]][index[j][1]] = True
if (bingo[0][0] and bingo[1][0] and bingo[2][0]) or (bingo[0][1] and bingo[1][1] and bingo[2][1]) or (bingo[0][2] and bingo[1][2] and bingo[2][2]):
    print('Yes')
elif (bingo[0][0] and bingo[0][1] and bingo[0][2]) or (bingo[1][0] and bingo[1][1] and bingo[1][2]) or (bingo[2][0] and bingo[2][1] and bingo[2][2]):
    print('Yes')
elif (bingo[0][0] and bingo[1][1] and bingo[2][2]) or (bingo[0][2] and bingo[1][1] and bingo[2][0]):
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
A = [input().split() for l in range(3)]
N=int(input())
b = [input() for l in range(N)]

for i in range(3):
    for j in range(3):
        for k in b:
            if A[i][j]==k:
                A[i][j]='*'

if (A[0][0]==A[0][1]==A[0][2]) or (A[1][0]==A[1][1]==A[1][2]) or (A[2][0]==A[2][1]==A[2][2]) or (A[0][0]==A[0][1]==A[0][2]) or (A[1][0]==A[1][1]==A[1][2]) or (A[2][0]==A[2][1]==A[2][2]) or (A[1][1]==A[2][2]==A[0][0]) or (A[0][2]==A[1][1]==A[2][0]):
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
A1 = list(map(int, input().split()))
A2 = list(map(int, input().split()))
A3 = list(map(int, input().split()))
N = int(input())
b = []
for i in range(N):
    b.append(int(input()))

A4 = []
A5 = []
A6 = []
A7 = []
A8 = []

A4.append(A1[0])
A4.append(A2[0])
A4.append(A3[0])

A5.append(A1[1])
A5.append(A2[1])
A5.append(A3[1])

A6.append(A1[2])
A6.append(A2[2])
A6.append(A3[2])

A7.append(A1[0])
A7.append(A2[1])
A7.append(A3[2])

A8.append(A1[2])
A8.append(A2[2])
A8.append(A3[0])

if b.count(A1[0]) + b.count(A1[1]) + b.count(A1[2]) == 3:
    print ("Yes")
    exit (0)
if b.count(A2[0]) + b.count(A2[1]) + b.count(A2[2]) == 3:
    print ("Yes")
    exit (0)
if b.count(A3[0]) + b.count(A3[1]) + b.count(A3[2]) == 3:
    print ("Yes")
    exit (0)
if b.count(A4[0]) + b.count(A4[1]) + b.count(A4[2]) == 3:
    print ("Yes")
    exit (0)
if b.count(A5[0]) + b.count(A5[1]) + b.count(A5[2]) == 3:
    print ("Yes")
    exit (0)
if b.count(A6[0]) + b.count(A6[1]) + b.count(A6[2]) == 3:
    print ("Yes")
    exit (0)
if b.count(A7[0]) + b.count(A7[1]) + b.count(A7[2]) == 3:
    print ("Yes")
    exit (0)
if b.count(A8[0]) + b.count(A8[1]) + b.count(A8[2]) == 3:
    print ("Yes")
    exit (0)

print ("No")

Submission status: Wrong Answer

Solution code:
a=[]
for i in range(3):
  a.append(list(map(int,input().split())))
n = int(input())
x = 0

for i in range(n):
  b = int(input())
  for j in range(3):
    for k in range(3):
      if a[j][k] == b:
        a[j][k] = 0

if (a[0][0] == 0 and a[2][2] == 0 and a[1][1] == 0) or (a[0][2] == 0 and a[2][0] == 0 and a[1][1] == 0): #斜めに揃っていたら
  print("Yes")
  x = 1
for i in range(3):
  if a[i][0] == 0 and a[i][1] == 0 and a[i][2] and x == 0: #横に揃っていたら
    print("Yes")
    x = 1
    break
  elif a[0][i] == 0 and a[1][i] == 0 and a[2][i] and x == 0: #縦に揃っていたら
    print("Yes")
    x = 1
    break
if x == 0:
  print("No")

Submission status: Wrong Answer

Solution code:
a=[]
for i in range(3):
  a.append(list(map(int,input().split())))
n = int(input())
x = 0

for i in range(n):
  b = int(input())
  for j in range(3):
    for k in range(3):
      if a[j][k] == b:
        a[j][k] = 0

print(a)

if (a[0][0] == 0 and a[2][2] == 0 and a[1][1] == 0) or (a[0][2] == 0 and a[2][0] == 0 and a[1][1] == 0): #斜めに揃っていたら
  print("Yes")
  x = 1
for i in range(3):
  if a[i][0] == 0 and a[i][1] == 0 and a[i][2] and x == 0: #横に揃っていたら
    print("Yes")
    x = 1
    break
  elif a[0][i] == 0 and a[1][i] == 0 and a[2][i] and x == 0: #縦に揃っていたら
    print("Yes")
    x = 1
    break
if x == 0:
  print("No")

Submission status: Wrong Answer

Solution code:
card_size = 3
c = []
for i in range(card_size):
  c.append(list(map(int, input().split())))

a = []
for i in range(card_size):
  a_ = []
  for j in range(card_size):
    a_.append(c[i][j])

  a.append(a_)

for i in range(card_size):
  a_ = []
  for j in range(card_size):
    a_.append(c[j][i])

  a.append(a_)

a_ = []
for i in range(card_size):
  a_.append(c[i][i])

a.append(a_)

for i in range(card_size):
  a_.append(c[i][card_size-i-1])

a.append(a_)

maru = [
    [0, 0, 0],
    [0, 0, 0],
    [0, 0, 0],
    [0, 0, 0],
    [0, 0, 0],
    [0, 0, 0],
    [0, 0, 0],
    [0, 0, 0],
]
 
ans = 0
n = int(input())
for i in range(n):
    b = int(input())
    for j in range(8):
        for k in range(3):
            if b == a[j][k]:
                maru[j][k] = 1
                if maru[j] == [1, 1, 1]:
                    ans = 1
 
if ans == 1:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
a11, a12, a13 = map(int, input().split())
a21, a22, a23 = map(int, input().split())
a31, a32, a33 = map(int, input().split())

a = [
    [a11, a12, a13],
    [a21, a22, a23],
    [a31, a32, a33],
    [a11, a21, a31],
    [a12, a22, a32],
    [a13, a23, a33],
    [a11, a22, a33],
    [a13, a22, a31],
]

maru = [
    [0, 0, 0],
    [0, 0, 0],
    [0, 0, 0],
    [0, 0, 0],
    [0, 0, 0],
    [0, 0, 0],
    [0, 0, 0],
    [0, 0, 0],
]

ans = 0
n = int(input())
for i in range(n):
    b = int(input())
    for j in range(8):
        for k in range(3):
            if b == a[j][k]:
                maru[j][k] = 1
                if maru[j] == [1, 1, 1]:
                    ans = 1
                    break
                else:
                    ans = 0
if ans == 1:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
def gg(s):
    for i in range(3):
        if s[i][0]==s[i][1] and s[i][0]==s[i][2]:
            return 'bingo'
    for r in range(3):
        if s[0][r]==s[1][r] and s[0][r]==s[2][r]:
            return 'bingo'
    if s[0][0]==s[1][1] and s[1][1]==s[2][2]:
        return 'bingo'
    
T=[]
l=[]
for i in range(3):
    a=input().split()
    l.append(a)
N=int(input())
for t in range(N):
    e=input()
    if e in l:
        l[e]='q'
    
if gg(l)=='bingo':
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
def gg(s):
    for i in range(3):
        if s[i][0]==s[i][1] and s[i][0]==s[i][2]:
            return 'bingo'
    for r in range(3):
        if s[0][r]==s[1][r] and s[0][r]==s[2][r]:
            return 'bingo'
    if s[0][0]==s[1][1] and s[1][1]==s[2][2]:
        return 'bingo'
    
T=[]
l=[]
for i in range(3):
    a=input().split()
    l.append(a)
N=int(input())
for t in range(N):
    e=input()
    if e in l:
        l[e]='q'
    
if gg(l)=='bingo':
    print('Yes')
else:
    print('No')
    
print(l)

Submission status: Wrong Answer

Solution code:
def gg(s):
    
    for i in s:
        for m in i:
            if m==i[0]:
                return 'bingo'
    for r in range(3):
        if s[0][r]==s[1][r] and s[0][r]==s[2][r]:
            return 'bingo'
    if s[0][0]==s[1][1] and s[1][1]==s[2][2]:
        return 'bingo'
    
T=[]
l=[]
for i in range(3):
    a=input().split()
    l.append(a)
N=int(input())
for t in range(N):
    e=input()
    if e in l:
        l[e]='q'
    
if gg(l)=='bingo':
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
A11,A12,A13 = list(map(int, input().split()))
A21,A22,A23 = list(map(int, input().split()))
A31,A32,A33 = list(map(int, input().split()))
l=[[A11,A12,A13],[A21,A22,A23],[A31,A32,A33],[A11,A22,A33],[A13,A22,A11],[A11,A21,A31],[A12,A22,A32],[A13,A23,A33]]
N = int(input())
b = []
for i in range(N):
    b = int(input())
    for j in range(8):
        if b in l[j]:
            l[j].remove(b)
f=1
for i in range(8):
    if l[i]==[]:
        print('Yes')
        f-=1
        break
if f==1:
    print('No')

Submission status: Wrong Answer

Solution code:
A11,A12,A13 = list(map(int, input().split()))
A21,A22,A23 = list(map(int, input().split()))
A31,A32,A33 = list(map(int, input().split()))
l=[[A11,A12,A13],[A21,A22,A23],[A31,A32,A33],[A11,A22,A33],[A13,A22,A11],[A11,A21,A31],[A12,A22,A32],[A13,A23,A33]]
N = int(input())
b = []
for i in range(N):
    b = int(input())
    for j in range(8):
        if b in l[j]:
            l[j].remove(b)
f=1
print(l)
for i in range(8):
    if l[i]==[]:
        print('Yes')
        f-=1
        break
if f==1:
    print('No')

Submission status: Wrong Answer

Solution code:
a=[[0]*3]*3
wk=[[0]*3]*3
a[0]=input().split()
a[1]=input().split()
a[2]=input().split()
n=int(input())
chk=False
for i in range(n):
  chk=False
  b=input()
  for j in range(3):
    if chk:
      break
    for k in range(3):
      if chk:
        break
      if a[j][k]==b:
        wk[j][k]=1
        chk=True
if [wk[0][0],wk[0][1],wk[0][2]]==[1,1,1]:
  print("Yes")
elif [wk[1][0],wk[1][1],wk[1][2]]==[1,1,1]:
  print("Yes")
elif [wk[2][0],wk[2][1],wk[2][2]]==[1,1,1]:
  print("Yes")
elif [wk[0][0],wk[1][1],wk[2][2]]==[1,1,1]:
  print("Yes")
elif [wk[0][2],wk[1][2],wk[2][2]]==[1,1,1]:
  print("Yes")
elif [wk[0][1],wk[1][1],wk[2][1]]==[1,1,1]:
  print("Yes")
elif [wk[0][0],wk[1][0],wk[2][0]]==[1,1,1]:
  print("Yes")
elif [wk[0][2],wk[1][1],wk[2][0]]==[1,1,1]:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
list = []
list1 = []
list2 = []
list3 = []
list5 = []
list1 = input().split()
list2 = input().split()
list3 = input().split()
list6 = []
list.extend(list1)
list.extend(list2)
list.extend(list3)
n = int(input())
b = 1
for i in range(0,n):
    a = (input())
    list5.append(a)
list.extend(list5)
for i in list:
    if i not in list6:
        list6.append(i)
    else:
        print('Yes')
        b = 0
        break
if b == 1:
    print('No')

Submission status: Wrong Answer

Solution code:
list = []
list1 = []
list2 = []
list3 = []
list5 = []
list1 = input().split()
list2 = input().split()
list3 = input().split()
list.extend(list1)
list.extend(list2)
list.extend(list3)
n = int(input())
b = 1
for i in range(0,n):
    a = (input())
    list5.append(a)
for item in list5:
        for items in list:
            if items==item:
                print('Yes')
                b = 1
            break
if b!=1:
    print('No')

Submission status: Wrong Answer

Solution code:
list = []
list1 = []
list2 = []
list3 = []
list5 = []
list1 = input().split()
list2 = input().split()
list3 = input().split()
list.extend(list1)
list.extend(list2)
list.extend(list3)
n = int(input())
a = 1
for i in range(0,n):
    a = (input())
    list5.append(a)
for item in list5:
        for items in list:
            if items==item:
                print('Yes')
                a = 1
            break
if a!=1:
    print('No')

Submission status: Wrong Answer

Solution code:
list = []
list1 = []
list2 = []
list3 = []
list5 = []
list1 = input().split()
list2 = input().split()
list3 = input().split()# separate by whitespace
list.extend(list1)
list.extend(list2)
list.extend(list3)
n = int(input())
a = 1
for i in range(0,n):
    a = (input())
    list5.append(a)
for item in list5:
        for items in list:
            if items==item:
                print('Yes')
                a = 1
            break
if a==1:
    a=1
else:
    print('No')

Submission status: Wrong Answer

Solution code:
*inputs, = map(int, open(0).read().split())
A = inputs[:9]
B = inputs[9:]

C = [0] * 9
for b in B:
  if b in A:
    C[A.index(b)] = 1
    
if any([
     all(C[:3]), all(C[3:6]), all(C[6:]),
     all(C[::3]), all(C[1::3]), all(C[2::3]),
     all([C[0], C[4], C[8]]), all([C[2], C[4], C[6]])
    ]):
  print('Yes')
else:
  print('No')
print(C)

Submission status: Wrong Answer

Solution code:
#Bingo
A = [ [] for _ in range(3)]
A[0] = list(map(int,input().split()))
A[1] = list(map(int,input().split()))
A[2] = list(map(int,input().split()))
N = int(input())
B = [int(input()) for _ in range(N)]
L = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]

for i in range(N):
    for j in range(3):
        for k in range(3):
            if A[j][k] == B[i]:
                L[j][k] = 1

if L[0][0] == L[0][1] == L[0][2]:
    print("Yes")
elif L[1][0] == L[1][1] == L[1][2]:
    print("Yes")
elif L[2][0] == L[2][1] == L[2][2]:
    print("Yes")
elif L[0][0] == L[1][0] == L[2][0]:
    print("Yes")
elif L[0][1] == L[1][1] == L[2][1]:
    print("Yes")
elif L[0][2] == L[1][2] == L[2][2]:
    print("Yes")
elif L[0][0] == L[1][1] == L[2][2]:
    print("Yes")
elif L[0][2] == L[1][1] == L[2][0]:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
#Bingo
A = [ [] for _ in range(3)]
A[0] = list(map(int,input().split()))
A[1] = list(map(int,input().split()))
A[2] = list(map(int,input().split()))
N = int(input())
B = [int(input()) for _ in range(N)]
L = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]

for i in range(N):
    for j in range(3):
        for k in range(3):
            if A[j][k] == B[i]:
                L[j][k] = 1

if L[0][0] == L[0][1] == L[0][2]:
    print("Yes")
elif L[1][0] == L[1][1] == L[1][2]:
    print("Yes")
elif L[2][0] == L[2][1] == L[2][2]:
    print("Yes")
elif L[0][0] == L[1][0] == L[2][0]:
    print("Yes")
elif L[0][1] == L[1][1] == L[2][1]:
    print("Yes")
elif L[0][2] == L[1][2] == L[2][2]:
    print("Yes")
elif L[0][0] == L[1][1] == L[2][2]:
    print("Yes")
elif L[0][2] == L[1][1] == L[0][2]:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
a = []
a.append(list(map(int, input().split())))
a.append(list(map(int, input().split())))
a.append(list(map(int, input().split())))
n = int(input())
b = []
bingo_cnt = 3
cnt1 = 0
cnt2 = 0
cnt3 = 0
cnt_diag = 0
cnt_diag_rev = 0
is_bingo = False

for i in range(n):
    b.append(int(input()))
    
for i in range(len(a)):
    cnt = 0
    for j in range(len(a[i])):
        if a[i][j] in b:
            cnt = cnt + 1
            if j is 0:
                cnt1 = cnt1 + 1
            if j is 1:
                cnt2 = cnt2 + 1
            if j is 2:
                cnt3 = cnt3 + 1
            if i == j:
                cnt_diag = cnt_diag + 1
            if (i is 0 and j is 2) or (j is 0 and i is 2) or (i is 1 and j is 1):
                cnt_diag_rev = cnt_diag_rev + 1
        
        if cnt is 3 or cnt1 is 3 or cnt2 is 3 or cnt3 is 3 or cnt_diag is 3 or cnt_diag_rev is 3:
            print("Yes")
            is_bingo = True
            break

if is_bingo is False:
    print("No")

Submission status: Wrong Answer

Solution code:
a = []
a.append(list(map(int, input().split())))
a.append(list(map(int, input().split())))
a.append(list(map(int, input().split())))
n = int(input())
b = []
bingo_cnt = 3
cnt1 = 0
cnt2 = 0
cnt3 = 0
cnt_diag = 0
cnt_diag_rev = 0
is_bingo = False

for i in range(n):
    b.append(int(input()))
    
for i in range(len(a)):
    cnt = 0
    for j in range(len(a[i])):
        if a[i][j] in b:
            cnt = cnt + 1
            if j is 0:
                cnt1 = cnt1 + 1
            if j is 1:
                cnt2 = cnt2 + 1
            if j is 2:
                cnt3 = cnt3 + 1
            if i == j:
                cnt_diag = cnt_diag + 1
                cnt_diag_rev = cnt_diag_rev + 1
            if (i is 0 and j is 2) or (j is 0 and i is 2):
                cnt_diag_rev = cnt_diag_rev + 1
        
        if cnt is 3 or cnt1 is 3 or cnt2 is 3 or cnt3 is 3 or cnt_diag is 3 or cnt_diag_rev is 3:
            print("Yes")
            is_bingo = True
            break

if is_bingo is False:
    print("No")

Submission status: Wrong Answer

Solution code:
a = []
a.append(list(map(int, input().split())))
a.append(list(map(int, input().split())))
a.append(list(map(int, input().split())))
n = int(input())
b = []
bingo_cnt = 3
cnt1 = 0
cnt2 = 0
cnt3 = 0
cnt_diag = 0
cnt_diag_rev = 0
is_bingo = False

for i in range(n):
    b.append(int(input()))
    
for i in range(len(a)):
    for j in range(len(a[i])):
        cnt = 0
        
        if a[i][j] in b:
            cnt = cnt + 1
            if j is 0:
                cnt1 = cnt1 + 1
            if j is 1:
                cnt2 = cnt2 + 1
            if j is 2:
                cnt3 = cnt3 + 1
            if i == j:
                cnt_diag = cnt_diag + 1
                cnt_diag_rev = cnt_diag_rev + 1
            if (i is 0 and j is 2) or (j is 0 and i is 2):
                cnt_diag_rev = cnt_diag_rev + 1
        
        if cnt is 3 or cnt1 is 3 or cnt2 is 3 or cnt3 is 3 or cnt_diag is 3 or cnt_diag_rev is 3:
            print("Yes")
            is_bingo = True
            break

if is_bingo is False:
    print("No")

Submission status: Wrong Answer

Solution code:
a = []
a.append(list(map(int, input().split())))
a.append(list(map(int, input().split())))
a.append(list(map(int, input().split())))
n = int(input())
b = []
bingo_cnt = 3
cnt1 = 0
cnt2 = 0
cnt3 = 0
cnt_diag = 0
is_bingo = False

for i in range(n):
    b.append(int(input()))
    
for i in range(len(a)):
    for j in range(len(a[i])):
        cnt = 0
        
        if a[i][j] in b:
            cnt = cnt + 1
            if j is 0:
                cnt1 = cnt1 + 1
            if j is 1:
                cnt2 = cnt2 + 1
            if j is 2:
                cnt3 = cnt3 + 1
            if i == j:
                cnt_diag = cnt_diag + 1
        
        if cnt is 3 or cnt1 is 3 or cnt2 is 3 or cnt3 is 3 or cnt_diag is 3:
            print("Yes")
            is_bingo = True
            break

if is_bingo is False:
    print("No")

Submission status: Wrong Answer

Solution code:
import sys
A1 = list(map(int, sys.stdin.readline().split()))
A2 = list(map(int, sys.stdin.readline().split()))
A3 = list(map(int, sys.stdin.readline().split()))
N = int(sys.stdin.readline())
b = [int(sys.stdin.readline()) for _ in range(N)]
A = A1 + A2 + A3
i = 0
while i <= 8:
  if b.count(A[i]):
    A[i] = 101
  i += 1
bingoFlag = False
k = 0
while k <= 2:
  if A[k] == A[k+3] == A[k+6]:
    bingoFlag = True
    break
  k += 1
if A[0] == A[4] == A[8] or A[2] == A[4] == A[6]:
  bingoFlag = True
if bingoFlag:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
A=[list(map(int,input().split())) for _ in range(3)]
N=int(input())
bn=[int(input()) for _ in range(N)]
ans=False
for ver in zip(*A):
    if all(item in bn for item in ver):
        ans=True
for wide in A:
    if all(item in bn for item in wide):
        ans=True
if all(A[i][i] in bn for i in range(3)):
    ans=True
if all(A[i][3-1] in bn for i in range(3)):
    ans=True
if ans==True:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
bingo = []
for i in range(3):
    a = list(map(int, input().split()))
    bingo += a
tmp = [0] * 9
n = int(input())
for i in range(n):
    b = int(input())
    if b in bingo:
        tmp[bingo.index(b)] = 1

if tmp[4]:
    if (tmp[0] and tmp[8]) or (tmp[1] and tmp[7]) or (tmp[2] and tmp[6]) and (tmp[3] and tmp[5]):
        print("Yes")
        exit()
if tmp[0]:
    if (tmp[1] and tmp[2]) or (tmp[3] and tmp[6]):
        print("Yes")
        exit()
if tmp[8]:
    if (tmp[6] and tmp[7]) or (tmp[2] and tmp[5]):
        print("Yes")
        exit()
print("No")

Submission status: Wrong Answer

Solution code:
bingo = []
for i in range(3):
    a = list(map(int, input().split()))
    bingo += a
tmp = [0] * 9
n = int(input())
for i in range(n):
    b = int(input())
    if b in bingo:
        tmp[bingo.index(b)] = 1

if tmp[4]:
    if (tmp[0] and tmp[8]) or (tmp[1] and tmp[7]) or (tmp[2] and tmp[6]) and (tmp[3] and tmp[5]):
        print("Yes")
        exit()
elif tmp[0]:
    if (tmp[1] and tmp[2]) or (tmp[3] and tmp[6]):
        print("Yes")
        exit()
elif tmp[8]:
    if (tmp[6] and tmp[7]) or (tmp[2] and tmp[5]):
        print("Yes")
        exit()
print("No")

Submission status: Wrong Answer

Solution code:
bingo = []
for i in range(3):
    a = list(map(int, input().split()))
    bingo += a
tmp = [0] * 9
n = int(input())
for i in range(n):
    b = int(input())
    if b in bingo:
        tmp[bingo.index(b)] = 1

if tmp[4]:
    if (tmp[0] and tmp[8]) or (tmp[1] and tmp[7]) or (tmp[2] and tmp[6]) and (tmp[3] and tmp[5]):
        print("Yes")
elif tmp[0]:
    if (tmp[1] and tmp[2]) or (tmp[3] and tmp[6]):
        print("Yes")
elif tmp[8]:
    if (tmp[6] and tmp[7]) or (tmp[2] and tmp[5]):
        print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
bingonum=[[0,0,0],[0,0,0],[0,0,0]]
bingo=[["False","False","False"],["False","False","False"],["False","False","False"]]
for i in range(3):
    bingonum[i][0],bingonum[i][1],bingonum[i][2] = map(int,input().split())
N = int(input())
b=[]
for _ in range(N):
    b.append(int(input()))
print(bingonum[0][0])
print(b[0])
for x in range(N):
    for i in range(3):
        for j in range(3):
            if bingonum[i][j]==b[x]:
                bingo[i][j]="True"
IsBingo = "No"
for i in range(3):
    if bingo[i][0]=="True" and bingo[i][1]=="True" and bingo[i][2]=="True":
        IsBingo="Yes"
    if bingo[0][i]=="True" and bingo[1][i]=="True" and bingo[2][i]=="True":
        IsBingo="Yes"
if (bingo[0][0]=="True" and bingo[1][1]=="True" and bingo[2][2]=="True") or (bingo[0][2]=="True" and bingo[1][1]=="True" and bingo[2][0]=="True"):
    IsBingo="Yes"
print(IsBingo)

Submission status: Wrong Answer

Solution code:
bingonum=[[0,0,0],[0,0,0],[0,0,0]]
bingo=[["False","False","False"],["False","False","False"],["False","False","False"]]
for i in range(3):
    bingonum[i][0],bingonum[i][1],bingonum[i][2] = map(int,input().split())

N = int(input())
b=[]
for _ in range(N):
    b.append(int(input()))
print(bingonum[0][0])
print(b[0])
for x in range(N):
    for i in range(3):
        for j in range(3):
            if bingonum[i][j]==b[x]:
                bingo[i][j]="True"

IsBingo = "No"
for i in range(3):
    if bingo[i][0]=="True" and bingo[i][1]=="True" and bingo[i][2]=="True":
        IsBingo="Yes"
    elif bingo[0][i]=="True" and bingo[1][i]=="True" and bingo[2][i]=="True":
        IsBingo="Yes"
if (bingo[0][0]=="True" and bingo[1][1]=="True" and bingo[2][2]=="True") or (bingo[0][2]=="True" and bingo[1][1]=="True" and bingo[2][0]=="True"):
    IsBingo="Yes"
print(IsBingo)

Submission status: Wrong Answer

Solution code:
a = [list(map(int,input().split())) for _ in range(3)]
n = int(input())
b = [int(input()) for _ in range(n)]
ati = [[a[0][i],a[1][i],a[2][i]] for i in range(3)]
an1 = [a[0][0],a[1][1],a[2][2]]
an2 = [a[0][2],a[1][1],a[2][0]]
for i in a:
  all(j in b for j in i)
  print('Yes')
  exit()
for i in ati:
  all(j in b for j in i)
  print('Yes')
  exit()
for i in an1:
  all(j in b for j in i)
  print('Yes')
  exit()
for i in an2:
  all(j in b for j in i)
  print('Yes')
  exit()
print('No')