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:
import sys

A = []

flag_First = True
for Count in range(3):
    for x in input().split(' '):
        x.strip('\n')
        InputValue = int(x)
        if 1<=int(x)<=100:
            if flag_First==True:
                A.append (InputValue)
                flag_First = False
            else:
                for Index in A:
                    if Index == InputValue:
                        sys.exit()

                A.append (InputValue)
        else:
            sys.exit()

N = int(input())
if N<=0 and N>10:
    sys.exit()

B = []
for Count in range(1,N+1):
    InputValue = int(input())
    if 1<=InputValue<=100:
        if Count == 1:
            B.append (InputValue)
        else:
            for Index in B:
                if Index == InputValue:
                    sys.exit()

            B.append (InputValue)

Bingo =[0,0,0,0,0,0,0,0,0]

for Item_B in B:
    for Index,Item_A in enumerate(A):
        if Item_A == Item_B:
            Bingo[Index]= 1

def CheckHorizontalBingo(Start,End):

    Flag_Bingo = True
    for Index,Item in enumerate(Bingo):
        if Start<=Index<=End:
            if Item == 0 :
                Flag_Bingo = False

    if Flag_Bingo == True:
        print('YES')
        sys.exit()

CheckHorizontalBingo(0,2)
CheckHorizontalBingo(3,5)
CheckHorizontalBingo(6,8)

def CheckVerticalBingo(One,Two,There):

    Flag_Bingo = True
    for Index,Item in enumerate(Bingo):
        if Index==One or Index==Two or Index==There:
            if Item == 0 :
                Flag_Bingo = False

    if Flag_Bingo == True:
        print('YES')
        sys.exit()

CheckVerticalBingo(0,3,6)
CheckVerticalBingo(1,4,7)
CheckVerticalBingo(2,5,8)

def CheckDiagonalBingo(One,Two,There):

    Flag_Bingo = True
    for Index,Item in enumerate(Bingo):
        if Index==One or Index==Two or Index==There:
            if Item == 0 :
                Flag_Bingo = False

    if Flag_Bingo == True:
        print('YES')
        sys.exit()

CheckDiagonalBingo(0,4,8)
CheckDiagonalBingo(3,5,7)

print('No')

Submission status: Wrong Answer

Solution code:
import sys

A = []

flag_First = True
for Count in range(3):
    for x in input().split(' '):
        x.strip('\n')
        InputValue = int(x)
        if 1<=int(x)<=100:
            if flag_First==True:
                A.append (InputValue)
                flag_First = False
            else:
                for Index in A:
                    if Index == InputValue:
                        sys.exit()

                A.append (InputValue)
        else:
            sys.exit()

N = int(input())
if N<=0 and N>10:
    sys.exit()

B = []
for Count in range(1,N+1):
    InputValue = int(input())
    if 1<=InputValue<=100:
        if Count == 1:
            B.append (InputValue)
        else:
            for Index in B:
                if Index == InputValue:
                    sys.exit()

            B.append (InputValue)

Bingo =[0,0,0,0,0,0,0,0,0]

for Item_B in B:
    for Index,Item_A in enumerate(A):
        if Item_A == Item_B:
            Bingo[Index]= 1

def CheckHorizontalBingo(Start,End):

    Flag_Bingo = True
    for Index,Item in enumerate(Bingo):
        if Start<=Index<=End:
            if Item == 0 :
                Flag_Bingo = False

    if Flag_Bingo == True:
        print(1,'YES')
        sys.exit()

CheckHorizontalBingo(0,2)
CheckHorizontalBingo(3,5)
CheckHorizontalBingo(6,8)

def CheckVerticalBingo(One,Two,There):

    Flag_Bingo = True
    for Index,Item in enumerate(Bingo):
        if Index==One or Index==Two or Index==There:
            if Item == 0 :
                Flag_Bingo = False

    if Flag_Bingo == True:
        print('YES')
        sys.exit()

CheckVerticalBingo(0,3,6)
CheckVerticalBingo(1,4,7)
CheckVerticalBingo(2,5,8)

def CheckDiagonalBingo(One,Two,There):

    Flag_Bingo = True
    for Index,Item in enumerate(Bingo):
        if Index==One or Index==Two or Index==There:
            if Item == 0 :
                Flag_Bingo = False

    if Flag_Bingo == True:
        print('YES')
        sys.exit()

CheckDiagonalBingo(0,4,8)
CheckDiagonalBingo(3,5,7)

print('No')

Submission status: Wrong Answer

Solution code:
import sys

A = []

flag_First = True
for Count in range(3):
    for x in input().split(' '):
        x.strip('\n')
        InputValue = int(x)
        if 1<=int(x)<=100:
            if flag_First==True:
                A.append (InputValue)
                flag_First = False
            else:
                for Index in A:
                    if Index == InputValue:
                        sys.exit()

                A.append (InputValue)
        else:
            sys.exit()

N = int(input())
if N<=0 and N>10:
    sys.exit()

B = []
for Count in range(1,N+1):
    InputValue = int(input())
    if 1<=InputValue<=100:
        if Count == 1:
            B.append (InputValue)
        else:
            for Index in B:
                if Index == InputValue:
                    sys.exit()

            B.append (InputValue)

Bingo =[0,0,0,0,0,0,0,0,0]

for Item_B in B:
    for Index,Item_A in enumerate(A):
        if Item_A == Item_B:
            Bingo[Index]= 1

def CheckHorizontalBingo(Start,End):

    Flag_Bingo = True
    for Index,Item in enumerate(Bingo):
        if Start<=Index<=End:
            if Item == 0 :
                Flag_Bingo = False

    if Flag_Bingo == True:
        print(1,'YES')
        sys.exit()

CheckHorizontalBingo(1,2)
CheckHorizontalBingo(3,5)
CheckHorizontalBingo(6,8)

def CheckVerticalBingo(One,Two,There):

    Flag_Bingo = True
    for Index,Item in enumerate(Bingo):
        if Index==One or Index==Two or Index==There:
            if Item == 0 :
                Flag_Bingo = False

    if Flag_Bingo == True:
        print('YES')
        sys.exit()

CheckVerticalBingo(0,3,6)
CheckVerticalBingo(1,4,7)
CheckVerticalBingo(2,5,8)

def CheckDiagonalBingo(One,Two,There):

    Flag_Bingo = True
    for Index,Item in enumerate(Bingo):
        if Index==One or Index==Two or Index==There:
            if Item == 0 :
                Flag_Bingo = False

    if Flag_Bingo == True:
        print('YES')
        sys.exit()

CheckDiagonalBingo(0,4,8)
CheckDiagonalBingo(3,5,7)

print('No')

Submission status: Wrong Answer

Solution code:
import sys

A = []

flag_First = True
for Count in range(3):
    for x in input().split(' '):
        x.strip('\n')
        InputValue = int(x)
        if 1<=int(x)<=100:
            if flag_First==True:
                A.append (InputValue)
                flag_First = False
            else:
                for Index in A:
                    if Index == InputValue:
                        sys.exit()

                A.append (InputValue)
        else:
            sys.exit()

N = int(input())
if N<=0 and N>10:
    sys.exit()

B = []
for Count in range(1,N+1):
    InputValue = int(input())
    if 1<=InputValue<=100:
        if Count == 1:
            B.append (InputValue)
        else:
            for Index in B:
                if Index == InputValue:
                    sys.exit()

            B.append (InputValue)

Bingo =[0,0,0,0,0,0,0,0,0]

for Item_B in B:
    for Index,Item_A in enumerate(A):
        if Item_A == Item_B:
            Bingo[Index]= 1

def CheckHorizontalBingo(Start,End):

    Flag_Bingo = True
    for Index,Item in enumerate(Bingo):
        if Start<=Index<=End:
            if Item == 0 :
                Flag_Bingo = False

    if Flag_Bingo == True:
        sys.exit()

CheckHorizontalBingo(1,2)
CheckHorizontalBingo(3,5)
CheckHorizontalBingo(6,8)

def CheckVerticalBingo(One,Two,There):

    Flag_Bingo = True
    for Index,Item in enumerate(Bingo):
        if Index==One or Index==Two or Index==There:
            if Item == 0 :
                Flag_Bingo = False

    if Flag_Bingo == True:
        sys.exit()

CheckVerticalBingo(0,3,6)
CheckVerticalBingo(1,4,7)
CheckVerticalBingo(2,5,8)

def CheckDiagonalBingo(One,Two,There):

    Flag_Bingo = True
    for Index,Item in enumerate(Bingo):
        if Index==One or Index==Two or Index==There:
            if Item == 0 :
                Flag_Bingo = False

    if Flag_Bingo == True:
        sys.exit()

CheckDiagonalBingo(0,4,8)
CheckDiagonalBingo(3,5,7)

print('No')

Submission status: Wrong Answer

Solution code:
import sys

A = []

flag_First = True
for Count in range(3):
    for x in input().split(' '):
        x.strip('\n')
        InputValue = int(x)
        if 1<=int(x)<=100:
            if flag_First==True:
                A.append (InputValue)
                flag_First = False
            else:
                for Index in A:
                    if Index == InputValue:
                        print(Index,InputValue)
                        print('値が重複しています。')
                        sys.exit()

                A.append (InputValue)
        else:
            sys.exit()

N = int(input())
if N<=0 and N>10:
    sys.exit()

B = []
for Count in range(1,N+1):
    InputValue = int(input())
    if 1<=InputValue<=100:
        if Count == 1:
            B.append (InputValue)
        else:
            for Index in B:
                if Index == InputValue:
                    print(Index,InputValue)
                    print('値が重複しています。')
                    sys.exit()

            B.append (InputValue)

Bingo =[0,0,0,0,0,0,0,0,0]

for Item_B in B:
    for Index,Item_A in enumerate(A):
        if Item_A == Item_B:
            Bingo[Index]= 1

print(Bingo)

def CheckHorizontalBingo(Start,End):

    Flag_Bingo = True
    for Index,Item in enumerate(Bingo):
        if Start<=Index<=End:
            if Item == 0 :
                Flag_Bingo = False

    if Flag_Bingo == True:
        print(1,'YES')
        sys.exit()

CheckHorizontalBingo(1,2)
CheckHorizontalBingo(3,5)
CheckHorizontalBingo(6,8)

def CheckVerticalBingo(One,Two,There):

    Flag_Bingo = True
    for Index,Item in enumerate(Bingo):
        if Index==One or Index==Two or Index==There:
            if Item == 0 :
                Flag_Bingo = False

    if Flag_Bingo == True:
        print(2,'YES')
        sys.exit()

CheckVerticalBingo(0,3,6)
CheckVerticalBingo(1,4,7)
CheckVerticalBingo(2,5,8)

def CheckDiagonalBingo(One,Two,There):

    Flag_Bingo = True
    for Index,Item in enumerate(Bingo):
        if Index==One or Index==Two or Index==There:
            if Item == 0 :
                Flag_Bingo = False

    if Flag_Bingo == True:
        print(2,'YES')
        sys.exit()

CheckDiagonalBingo(0,4,8)
CheckDiagonalBingo(3,5,7)

print('No')

Submission status: Wrong Answer

Solution code:
A, B, C = map(int, input().split())
D, E, F = map(int, input().split())
G, H, I = map(int, input().split())

N = int(input())

bingo_list = []

for i in range(1,N):
  num = int(input())
  bingo_list.append(num)

Submission status: Wrong Answer

Solution code:
bingo = []

for _ in range(3):
  l = map(int, input().split())
  d = {}
  for i in l:
    d[i] = False
  
  bingo.append(d)
  
n = int(input())
  
for _ in range(n):
  i = int(input())
  for j in range(3):
    if bingo[j].get(i) == False:
      bingo[j][i] = True

ans = "No"

for i in range(3):
  bingo[i] = list(bingo[i].values())
  if bingo[i][0] and bingo[i][1] and bingo[i][2]:
    ans = "Yes"
  
for i in range(3):
  if bingo[0][i] and bingo[1][i] and bingo[2][i]:
    ans = "Yes"
    
if bingo[0][0] and bingo[1][1] and bingo[2][2]:
  ans = "Yes"
  
if bingo[2][0] and bingo[1][1] and bingo[0][2]:
  ans = "Yes"
  
print(ans)

Submission status: Wrong Answer

Solution code:
bingo = []

for _ in range(3):
  l = map(int, input().split())
  d = {}
  for i in l:
    d[i] = False
  
  bingo.append(d)
  
n = int(input())
  
for _ in range(n):
  i = int(input())
  for j in range(3):
    if bingo[j].get(i) == False:
      bingo[j][i] = True

ans = "No"

for i in range(3):
  bingo[i] = list(bingo[i].values())
  if bingo[i].count(True) == 3:
    ans = "Yes"
  
for i in range(3):
  if bingo[0][i] == True and bingo[1][i] == True and bingo[2][i] == True:
    ans = "Yes"
    
if bingo[0][0] == True and bingo[1][1] == True and bingo[2][2] == True:
  ans = "Yes"
  
if bingo[2][0] == True and bingo[1][1] == True and bingo[0][2] == True:
  ans = "Yes"
  
print(ans)

Submission status: Wrong Answer

Solution code:
a = [list(map(int, input().split())) for l in range(3)]

#縦に並んだ標準入力読み込み
N = int(input()) #4行目のNを取得する
s = [int(input()) for i in range(N)] #複数行の数値の入力を取得

#各入力の値があったとき値を0に置き換え、これをN回やる（Nは10なのでムリやりでOK）
for nu in range(len(s)):
	for i in range(3):
		for j in range(3):
			if a[i][j] == s[nu]:
				a[i][j] = 0
#縦横斜めチェック
for r in range(3):
	if a[i][0]==a[i][1]==a[i][2]==0:
		print('Yes')
		exit()
	if a[0][i]==a[1][i]==a[2][i]==0:
		print('Yes')
		exit()

if a[0][0]==a[1][1]==a[2][2]==0	or a[0][2]==a[1][1]==a[2][0]==0:	
		print('Yes')
		exit() 
print('No')

Submission status: Wrong Answer

Solution code:
card = []

for _ in range(3):
    card.extend(map(int, input().split(' ')))

jadge = [0] * 9
N = int(input())

for _ in range(N):
    n = int(input())
    if n in card:
        jadge[card.index(n)] = 1

print(jadge)

bingo = False
for i in range(3):
    if (jadge[3 * i] + jadge[3 * i+1] + jadge[3 * i+2]) == 3:
        bingo = True
        break
    if (jadge[i] + jadge[3 + i] + jadge[6 + i]) == 3:
        bingo = True
        break
    if (jadge[i] + jadge[4] + jadge[8-i]) == 3:
        bingo = True
        break

if bingo:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
card = []

for _ in range(3):
  card.extend(map(int, input().split(' ')))

jadge = [0] * 9
N = int(input())

for _ in range(N):
  n = int(input())
  if n in card:
    jadge[card.index(n)] = 1

bingo = False
for i in range(3):
  if (jadge[i] + jadge[i+1] + jadge[i+2]) == 3:
    bingo = True
    break
  if (jadge[i] + jadge[3 + i] + jadge[6 + i]) == 3:
    bingo = True
  if (jadge[i] + jadge[4] + jadge[8-i]) == 3:
    bingo = True
    break

if bingo:
  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()))
seat = [a1, a2, a3]
n = int(input())
b = [int(input()) for i in range(n)]

seat_tf = [[False, False, False] for _ in range(3)]

for k in b:
    for i in range(3):
        for j in range(3):
            if seat[i][j] == b:
                seat_tf[i][j] = True

for i in range(3):
    if seat_tf[i][0] and seat_tf[i][1] and seat_tf[i][2]:
        print("Yes")
        exit()

for j in range(3):
    if seat_tf[0][j] and seat_tf[1][j] and seat_tf[2][j]:
        print("Yes")
        exit()

if (seat_tf[0][0] and seat_tf[1][1] and seat_tf[2][2]) or (seat_tf[0][2] and seat_tf[1][1] and seat_tf[2][0]):
    print("Yes")
    exit()
print("No")

Submission status: Wrong Answer

Solution code:
A = [list(map(int,input().split())) for i in range(3)]
A_flat=[]
for i in range(len(A)):
    A_flat.append(A[i][0])
    A_flat.append(A[i][1])
    A_flat.append(A[i][2])

N = int(input())
b = [int(input()) for i in range(N)]
for i in range(len(b)):
    if b[i] in A_flat:
        index = A_flat.index(b[i])
        A_flat[index] = 0

for i in range(3):
    if A_flat[0+i] == A_flat[3+i] == A_flat[6+i]:
        print("Yes")
        break
    elif A_flat[0+i]==A_flat[1+i]==A_flat[2+i]:
        print("Yes")
        break
    elif A_flat[0]==A_flat[4]==A_flat[8] or A_flat[2]==A_flat[4]==A_flat[6]:
        print("Yes")
        break
    if i == 2:
        print("No")

Submission status: Wrong Answer

Solution code:
import sys
rl = sys.stdin.readline

rows = 3
cols = 3
a11,a12,a13 = [int(x) for x in rl().split(' ')]
a12,a22,a23 = [int(x) for x in rl().split(' ')]
a31,a32,a33 = [int(x) for x in rl().split(' ')]

n = int(rl())
b = []

for i in range(n):
    b.append(int(rl()))

#####################

card = [a11,a12,a13,a11,a12,a13,a31,a32,a33]

for num in b:
    for i in range(len(card)):
        if card[i] == num:
            card[i] = 0

def check(card):
    for y in range(rows):
        if all([card[y*rows+x] == 0 for x in range(cols)]):
            return True

    # col
    for x in range(cols):
        if all([card[y*rows+x] == 0 for y in range(rows)]):
            return True

    # diagonal
    if all([card[xy*rows+xy] == 0 for xy in range(rows)]):
            return True

    if all([card[xy*rows+cols-1-xy] == 0 for xy in range(rows)]):
            return True

    return False

if check(card):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
import sys
rl = sys.stdin.readline

rows = 3
cols = 3
a11,a12,a13 = [int(x) for x in rl().split(' ')]
a11,a12,a13 = [int(x) for x in rl().split(' ')]
a31,a32,a33 = [int(x) for x in rl().split(' ')]

n = int(rl())
b = []

for i in range(n):
    b.append(int(rl()))

#####################

card = [a11,a12,a13,a11,a12,a13,a31,a32,a33]

for num in b:
    for i in range(len(card)):
        if card[i] == num:
            card[i] = 0

def check(card):
    for y in range(rows):
        if all([card[y*rows+x] == 0 for x in range(cols)]):
            return True

    # col
    for x in range(cols):
        if all([card[y*rows+x] == 0 for y in range(rows)]):
            return True

    # diagonal
    if all([card[xy*rows+xy] == 0 for xy in range(rows)]):
            return True

    if all([card[xy*rows+cols-1-xy] == 0 for xy in range(rows)]):
            return True

    return False

if check(card):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
a = []
for rep in range(3):
	a.append(list(map(int,input().split())))
n = int(input())
b = []
for rep in range(n):
    b.append(int(input()))
row = [0,0,0]
col = [0,0,0]
mid = 0
for i in range(3):
    for j in range(3):
        if a[i][j] in b:
            row[i] += 1
            col[j] += 1
            if i==2 and j==2:
                mid = 1
f = 1
for rep in range(3):
    if row[rep]==0 or col[rep]==0:
        f = 0
        break
if 3 in row or 3 in col:
    print("Yes")
elif f == 1 and mid == 1:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

for a in A:
    for b in B:
        if b in a:
            a[a.index(b)] = 0

ans = "No"
if [A[i][i] for i in range(3)] == [0, 0, 0]:
    ans = "Yes"
if [A[i][2-i] for i in range(3)] == [0, 0, 0]:
    ans = "Yes"
for i in range(3):
    if A[i] == [0, 0, 0]:
        ans = "Yes"
    if [A[i][j] for j in range(3)] == [0, 0, 0]:
        ans = "Yes"
print(ans)

Submission status: Wrong Answer

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

result = [[False, False, False], [False, False, False], [False, False, False]]
chk = 0
for r_idx, row in enumerate(table):
    for c_idx, col in enumerate(row):
        result[r_idx][c_idx] = col in p_list


for i in range(3):
    if result[i][0] and result[i][1] and result[i][2]:
        chk += 1
    if result[0][i] and result[1][i] and result[2][i]:
        chk += 1

if result[0][0] and result[1][1] and result[2][2]:
    chk += 1

if result[0][2] and result[1][1] and result[2][0]:
    chk += 1

print('YES' if chk > 0 else 'NO')

Submission status: Wrong Answer

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

result = [[False, False, False], [False, False, False], [False, False, False]]
chk = 0
for r_idx, row in enumerate(table):
    for c_idx, col in enumerate(row):
        result[r_idx][c_idx] = col in p_list

for i in range(3):
    if result[i][0] and result[i][1] and result[i][2]:
        chk += 1
    if result[0][i] and result[1][i] and result[2][i]:
        chk += 1
    if result[i][i] and result[i][i] and result[i][i]:
        chk += 1

if result[0][2] and result[1][1] and result[2][0]:
    chk += 1

print('YES' if chk > 0 else 'NO')

Submission status: Wrong Answer

Solution code:
a=[list(map(int,input().split())) for i in range(3)]
n=int(input())
b=[int(input()) for i in range(n)]
result=[[0]*3 for i in range(3)]
for i in range(3):
  for j in range(3):
    for k in range(n):
      if a[i][j]==b[k]:
        result[i][j]=1
for i in range(3):
  cnth=0
  cntw=0
  for j in range(3):
    cnth+=result[i][j]
    cntw+=result[j][i]
  if cnth or cntw==3:
    print('Yes')
    exit()
if result[0][0]==result[1][1]==result[2][2]==1 or result[0][2]==result[1][1]==result[2][0]==1:
  print('Yes')
  exit()
print('No')

Submission status: Wrong Answer

Solution code:
import sys

As = []
for i in range(3):
    tmp = list(map(int, input().split()))
    for j in range(3):
        As.append({'value': tmp[i], 'isMarked': False})


N = int(input())

for i in range(N):
    b = int(input())
    for Ai in As:
        if Ai['value'] == b:
            Ai['isMarked'] = True

bingo_list = [[0,1,2],[3,4,5],[6,7,8],  # 横
              [0,3,6],[1,4,7],[2,5,8],  # 縦
              [0,4,8],[2,4,6]]          # ななめ

for bingo in bingo_list:
    if As[bingo[0]]['isMarked'] and As[bingo[1]]['isMarked'] and As[bingo[2]]['isMarked']:
        print('Yes')
        sys.exit(0)

print('No')

Submission status: Wrong Answer

Solution code:
import sys

As = []
for i in range(3):
    tmp = list(map(int, input().split()))
    for j in range(3):
        As.append({'value': tmp[i], 'isMarked': False})


N = int(input())

for i in range(N):
    b = int(input())
    for Ai in As:
        if Ai['value'] == b:
            Ai['isMarked'] = True

bingo_list = [[0,1,2],[3,4,5],[6,7,8],  # 横
              [0,3,6],[1,4,7],[2,5,8],  # 縦
              [0,4,8],[2,4,5]]          # ななめ

for bingo in bingo_list:
    if As[bingo[0]]['isMarked'] and As[bingo[1]]['isMarked'] and As[bingo[2]]['isMarked']:
        print('Yes')
        sys.exit(0)

print('No')

Submission status: Wrong Answer

Solution code:
import sys

def calc_flag(b,a,flag):
    if b in a:
        # flag[a.index(b)] = 1
        l_index = [i for i, x in enumerate(a) if x == b]
        for l in l_index:
            flag[l]=1
    return flag

a1 = list(map(int,input().split()))
a2 = list(map(int,input().split()))
a3 = list(map(int,input().split()))
n = int(input())

flag1 = [0,0,0]
flag2 = [0,0,0]
flag3 = [0,0,0]

for i in range(n):
    b = int(input())
    flag1 = calc_flag(b,a1,flag1)
    flag2 = calc_flag(b,a2,flag2)
    flag3 = calc_flag(b,a3,flag3)

print(flag1,flag2,flag3)

for i in range(3): #tate
    if flag1[i]+flag2[i]+flag3[i]==3:
        print('Yes')
        sys.exit()

if flag1[0]+flag2[1]+flag3[2]==3 or flag1[2]+flag2[1]+flag3[0]==3: #naname
    print('Yes')
elif sum(flag1)==3 or sum(flag2)==3 or sum(flag3)==3: #yoko
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
import sys

a = [list(map(int,input().split())) for i in range(3)]
n = int(input())
b = [int(input()) for i in range(n)]
flag = [[0,0,0],[0,0,0],[0,0,0]]
# print(a,n,b,c)

for x in range(n):
    for i in range(3):
        for j in range(3):
            if a[i][j] == b[x]:
                flag[i][j] = 1
# print(c)

if sum(flag[0])==3 or sum(flag[1])==3 or sum(flag[2])==3: #横ビンゴ
    print('Yes')
    sys.exit()
if flag[0][0] == flag[1][1]==flag[2][2]==1: #斜めビンゴ
    print('Yes')
    sys.exit()
if flag[0][0]+flag[1][0]+flag[2][0]==3 or flag[0][1]+flag[1][1]+flag[2][1]==3 or flag[0][2]+flag[1][2]+flag[2][2]==3: #縦ビンゴ
    print('Yes')
    sys.exit()

print('No')

Submission status: Wrong Answer

Solution code:
import sys

a = [list(map(int,input().split())) for i in range(3)]
n = int(input())
b = [int(input()) for i in range(n)]
flag = [[0,0,0],[0,0,0],[0,0,0]]
# print(a,n,b,c)

for x in range(n):
    for i in range(3):
        for j in range(3):
            if a[i][j] == b[x]:
                flag[i][j] = 1
# print(c)

if sum(flag[0])==3 or sum(flag[1])==3 or sum(flag[2])==3: #横ビンゴ
    print('Yes')
    sys.exit()
elif flag[0][0] == flag[1][1]==flag[2][2]==1: #斜めビンゴ
    print('Yes')
    sys.exit()
elif flag[0][0]+flag[1][0]+flag[2][0]==3 or flag[0][1]+flag[1][1]+flag[2][1]==3 or flag[0][2]+flag[1][2]+flag[2][2]==3: #縦ビンゴ
    print('Yes')
    sys.exit()
else:
    print('No')

Submission status: Wrong Answer

Solution code:
a = []
for i in range(3):
    a += map(int, input().split())

n = int(input())

for i in range(n):
    b = int(input())
    for j in range(9):
        if b == a[j]:
            a[j] = 'o'

isBingo = False
bingo = [[0, 3, 6], [1, 4, 7], [2, 5, 8], [0, 1, 2], [3, 4, 5], [6, 7, 8], [0, 4, 8], [2, 5, 6]]
for elem in bingo:
    if a[elem[0]] == 'o' and a[elem[1]] == 'o' and a[elem[2]] == 'o':
        isBingo = True
        break

print('Yes') if isBingo else print('No')

Submission status: Wrong Answer

Solution code:
a = []
for i in range(3):
    a += map(int, input().split())

n = int(input())

for i in range(n):
    b = int(input())
    for j in range(9):
        if b == a[j]:
            a[j] = 'o'

isBingo = False
bingo = [[0, 3, 6], [1, 4, 7], [2, 5, 8], [0, 1, 2], [3, 4, 5], [6, 7, 8], [0, 4, 8], [2, 5, 7]]
for elem in bingo:
    if a[elem[0]] == 'o' and a[elem[1]] == 'o' and a[elem[2]] == 'o':
        isBingo = True
        break

print('Yes') if isBingo else print('No')

Submission status: Wrong Answer

Solution code:
a = []
for i in range(3):
    a += map(int, input().split())

n = int(input())

for i in range(n):
    b = int(input())
    for i in range(9):
        if b == a[i]:
            a[i] = 'o'

isBingo = False
bingo = [[0, 3, 6], [1, 4, 7], [2, 5, 8], [0, 1, 2], [3, 4, 5], [6, 7, 8], [0, 4, 8], [2, 5, 7]]
for elem in bingo:
    if a[elem[0]] == 'o' and a[elem[1]] == 'o' and a[elem[2]] == 'o':
        isBingo = True
        break

print('Yes') if isBingo else print('No')

Submission status: Wrong Answer

Solution code:
import sys

def calc_flag(b,a,flag):
    if b in a:
        # flag[a.index(b)] = 1
        l_index = [i for i, x in enumerate(a) if x == b]
        for l in l_index:
            flag[l]=1
    return flag

a1 = list(map(int,input().split()))
a2 = list(map(int,input().split()))
a3 = list(map(int,input().split()))
n = int(input())

flag1 = [0,0,0]
flag2 = [0,0,0]
flag3 = [0,0,0]

for i in range(n):
    b = int(input())
    flag1 = calc_flag(b,a1,flag1)
    flag2 = calc_flag(b,a2,flag2)
    flag3 = calc_flag(b,a3,flag3)

# print(flag1,flag2,flag3)

for i in range(3):
    if flag1[i]+flag2[i]+flag3[i]==3:
        print('Yes')
        sys.exit()

if flag1[0]+flag2[1]+flag3[2]==3:
    print('Yes')
elif sum(flag1)==3 or sum(flag2)==3 or sum(flag3)==3:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
import sys

def calc_flag(b,a,flag):
    if b in a:
        flag[a.index(b)] = 1
    return flag

a1 = list(map(int,input().split()))
a2 = list(map(int,input().split()))
a3 = list(map(int,input().split()))
n = int(input())

flag1 = [0,0,0]
flag2 = [0,0,0]
flag3 = [0,0,0]

for i in range(n):
    b = int(input())
    flag1 = calc_flag(b,a1,flag1)
    flag2 = calc_flag(b,a2,flag2)
    flag3 = calc_flag(b,a3,flag3)

# print(flag1,flag2,flag3)

for i in range(3):
    if flag1[i]+flag2[i]+flag3[i]==3:
        print('Yes')
        sys.exit()

if flag1[0]+flag2[1]+flag3[2]==3:
    print('Yes')
elif sum(flag1)==3 or sum(flag2)==3 or sum(flag3)==3:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
A1st = input().split(' ')
A2th = input().split(' ')
A3rd = input().split(' ')
Alist = []
ans = []
b = []
A11 = int(A1st[0]) ; A12 = int(A1st[1]) ; A13 = int(A1st[2])
A21 = int(A2th[0]) ; A22 = int(A2th[1]) ; A23 = int(A2th[2])
A31 = int(A3rd[0]) ; A32 = int(A3rd[1]) ; A33 = int(A3rd[2])
Alist.append(A11) ;Alist.append(A12) ; Alist.append(A13)
Alist.append(A21) ; Alist.append(A22) ; Alist.append(A23)
Alist.append(A31) ; Alist.append(A32) ; Alist.append(A33)
N = int(input())
for k in range(N):
    b.append(input())
for s in range(9):
    if str(Alist[s]) in b:
        ans.append(s+1)
if (1 and 2 and 3 in ans) or (4 and 5 and 6 in ans) or (7 and 8 and 9 in ans) or (1 and 4 and 7 in ans) or (2 and 5 and 8 in ans) or (3 and 6 and 9 in ans) or (1 and 5 and 9 in ans) or ( 3 and 5 and 7 in ans):
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
A1st = input().split(' ')
A2th = input().split(' ')
A3rd = input().split(' ')
Alist = []
ans = []
b = []
A11 = int(A1st[0]) ; A12 = int(A1st[1]) ; A13 = int(A1st[2])
A21 = int(A2th[0]) ; A22 = int(A2th[1]) ; A23 = int(A2th[2])
A31 = int(A3rd[0]) ; A32 = int(A3rd[1]) ; A33 = int(A3rd[2])
Alist.append(A11) ;Alist.append(A12) ; Alist.append(A13)
Alist.append(A21) ; Alist.append(A22) ; Alist.append(A23)
Alist.append(A31) ; Alist.append(A32) ; Alist.append(A33)
N = int(input())
for k in range(N):
    b.append(input())
for s in range(9):
    if str(Alist[s]) in b:
        ans.append(s+1)
ans.sort()
if (1 and 2 and 3 in ans) or (4 and 5 and 6 in ans) or (7 and 8 and 9 in ans) or (1 and 4 and 7 in ans) or (2 and 5 and 8 in ans) or (3 and 6 and 9 in ans) or (1 and 5 and 9 in ans) or ( 3 and 5 and 7 in ans):
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
import sys
card = [[int(x) for x in input().split(' ') ] for _ in range(3)]

patterns = []

patterns += [[card[i][j] for i in range(3)] for j in range(3)]
patterns += [[card[j][i] for i in range(3)] for j in range(3)]
patterns.append([card[i][i] for i in range(3)])
patterns.append([card[i][2-i] for i in range(3)] )

print(patterns)

ok = False
N = int(input())
for _ in range(N):
    b = int(input())
    for pat in patterns:
        while b in pat:
            pat.remove(b)
    
print(patterns)
        
for pat in patterns:
    if len(pat) == 0:
        print('Yes')
        sys.exit()

print('No')

Submission status: Wrong Answer

Solution code:
import sys
card = [[int(x) for x in input().split(' ') ] for _ in range(3)]

patterns = []

patterns += [[card[i][j] for i in range(3)] for j in range(3)]
patterns += [[card[j][i] for i in range(3)] for j in range(3)]
patterns.append([card[i][i] for i in range(3)])
patterns.append([card[2-i][2-i] for i in range(3)] )

ok = False
N = int(input())
for _ in range(N):
    b = int(input())
    for pat in patterns:
        if b in pat:
            pat.remove(b)
        
for pat in patterns:
    if len(pat) == 0:
        print('Yes')
        sys.exit()
        
print('No')