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 = [list(input().split()) for i in range(3)]
output =[[0,0,0],[0,0,0],[0,0,0]]
n = int(input())
for k in range(n):
    b=int(input())
    for i in range(3):
        for j in range(3):
            if a[i][j]==b:
                output[i][j]=1
for i in range(3):
    if output[i][0]*output[i][1]*output[i][2]==1:
        print('Yes')
    elif output[0][i]*output[1][i]*output[2][i]==1:
        print('Yes')
    else:
        continue
if output[0][0]*output[1][1]*output[2][2]==1:
    print('Yes')
elif output[2][0]*output[1][1]*output[0][2]==1:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import numpy as np
bingo = np.ndarray((3,3)).astype(np.int)
for i in range(3):
    line = list(map(int,input().split()))
    bingo[i] = line
N = int(input())

for _ in range(N):
    b = int(input())
    bingo[bingo==b] = 0
if np.max(bingo)==0:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
A = [[0]*3]*3
for i in range(3):
    A[i] = list(map(int,input().split()))
N = int(input())
for _ in range(N):
    a = int(input())
    for i in range(3):
        if a in A[i]:
            A[i][A[i].index(a)] = 0
for i in range(3):
    if A[i].count(0) == 3:
        print("Yes")
        exit()
for i in range(3):
    if A[0][i] == 0 and A[1][i] == 0 and A[2][i] == 0:
        print("Yes")
        exit()
for i in range(3):
    if A[i][i] != 0:
        break
    if i == 2:
        print("Yes")
        exit()
print("No")

Submission status: Wrong Answer

Solution code:
A = [[0]*3]*3
for i in range(3):
    A[i] = list(map(int,input().split()))
N = int(input())
for _ in range(N):
    a = int(input())
    for i in range(3):
        if a in A[i]:
            A[i][A[i].index(a)] = 0
for i in range(3):
    if A[i].count(0) == 3:
        print("Yes")
        exit()
for i in range(3):
    if A[0][i] != 0:
        break
    if i == 2:
        print("Yes")
        exit()
for i in range(3):
    if A[i][i] != 0:
        break
    if i == 2:
        print("Yes")
        exit()
print("No")

Submission status: Wrong Answer

Solution code:
l=[list(map(int,input().split())) for i in range(3)]
n=int(input())
H=[0,0,0]
W=[0,0,0]
S=[0,0]

for i in range(n):
    b=int(input())
    for h in range(3):
        for w in range(3):
            if b==l[h][w]:
                H[h]+=1
                W[w]+=1
                if h==w:
                    S[0]+=1
                if h+w==4:
                    S[1]+=1

check=False
for h in H:
    if h==3:
        check=True
for w in W:
    if w==3:
        check=True
for s in S:
    if s==3:
        check=True

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

Submission status: Wrong Answer

Solution code:
import numpy as np
N_1=[46, 70, 98]
N_2=[5, 39, 99]
N_3=[34, 84, 8]

N=int(7)
a=[75,12,22,8,99,34,10]

n=np.array([N_1,N_2,N_3])

for a_n in a:
    if a_n in n:
        n[n==a_n]=0
    else:
        pass
i=0
    
if np.all(n[0:,0]==0)==True:
    i=+1
    
elif np.all(n[0:,1]==0)==True:
    i+=1
    
elif np.all(n[0:,2]==0)==True:
    i+=1
    
elif np.all(n[0,0:]==0)==True:
    i+=1
    
elif np.all(n[1,0:]==0)==True:
    i+=1

elif np.all(n[2,0:]==0)==True:
    i+=1

elif n[0,0]==0 and n[1,1]==0  and n[2,2] ==0:
    i+=1
    
elif n[0,2]==0 and n[1,1]==0 and n[2,0] ==0:
    i+=1
    print(i)
if i>0:
    print("Yes")
else:
    print("No")

print(n)

Submission status: Wrong Answer

Solution code:
def bingo(marked):
    for i in range(3):
        all_marked = True
        for j in range(3):
            if not marked[i][j]:
                all_marked = False
        if all_marked:
            return True
    
    for i in range(3):
        all_marked = True
        for j in range(3):
            if not marked[j][i]:
                all_marked = False
        if all_marked:
            return True
    
    all_marked = True
    for i in range(3):
        if not marked[i][i]:
            all_marked = False
    if all_marked:
        return True
    
    all_marked = True
    for i in range(3):
        if not marked[2 - i][2 - i]:
            all_marked = False
    if all_marked:
        return True

    return False
            
A = [[] for i in range(3)]
marked=  [[False for i in range(3)] for j in range(3)]
for i in range(3):
    A[i] = list(map(int, input().split()))
N = int(input())
for i in range(N):
    b = int(input())
    for i in range(3):
        for j in range(3):
            if A[i][j] == b:
                marked[i][j] = True
                
if bingo(marked):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
bingoDict = {}
bingoList = []
pos = 0
mark = 0 

#Creates a list containing three lists for each row of numbers
for i in range(3):
  bingoList.append(list(map(int, input().split())))

#Iterates through list inside of list, adding them to a dictionary 
for row in range(len(bingoList)):
  for item in range(len(bingoList[row])):
    pos += 1
    tempList = [] 
    tempList.append(bingoList[row][item])
    tempList.append(0)
    bingoDict[pos] = tempList

#Number of numbers called 
N = int(input())

#If the number is mentioned, add one to value (could be more than 1)
for i in range(N):
  numCalled = int(input())
  for i in range(1, 10):
    if numCalled == bingoDict[i][0]:
      bingoDict[i][1] += 1
  
for key in bingoDict:
  if key + 6 <= 9:
    if bingoDict[key][1] and bingoDict[key + 3][1] and bingoDict[key + 6][1] >= 1:
      mark = 1
  if key + 2 <= 9:
    if bingoDict[key][1] and bingoDict[key + 1][1] and bingoDict[key + 2][1] >= 1:
      mark = 1
  if key + 8 <= 9:
    if bingoDict[key][1] and bingoDict[key + 4][1] and bingoDict[key + 8][1] >= 1:
      mark = 1
  if key + 4 <= 9:
    if bingoDict[key][1] and bingoDict[key + 2][1] and bingoDict[key + 4][1] >= 1:
      mark = 1

if mark == 1:
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

Solution code:
bingoDict = {}
bingoList = []
pos = 0

#Creates a list containing three lists for each row of numbers
for i in range(3):
  bingoList.append(list(map(int, input().split())))

#Iterates through list inside of list, adding them to a dictionary 
for row in range(len(bingoList)):
  for item in range(len(bingoList[row])):
    pos += 1
    tempList = [] 
    tempList.append(bingoList[row][item])
    tempList.append(0)
    bingoDict[pos] = tempList
    #print(bingoDict)

#Number of numbers called 
N = int(input())

#If the number is mentioned, add one to value (could be more than 1)
for i in range(N):
  numCalled = int(input())
  for i in range(1, 10):
    if numCalled == bingoDict[i][0]:
      bingoDict[i][1] += 1
  
for key in bingoDict:
  if key + 6 <= 9:
    if bingoDict[key][1] and bingoDict[key + 3][1] and bingoDict[key + 6][1] >= 1:
      print('Yes')
      break
  if key + 2 <= 9:
    if bingoDict[key][1] and bingoDict[key + 1][1] and bingoDict[key + 2][1] >= 1:
      print('Yes')
      break
  if key + 8 <= 9:
    if bingoDict[key][1] and bingoDict[key + 4][1] and bingoDict[key + 8][1] >= 1:
      print('Yes')
      break
  if key + 4 <= 9:
    if bingoDict[key][1] and bingoDict[key + 2][1] and bingoDict[key + 4][1] >= 1:
      print('Yes')
      break
  else:
    print('No')
    break

Submission status: Wrong Answer

Solution code:
import numpy as np
N_1=list(map(int, input().split()))
N_2=list(map(int, input().split()))
N_3=list(map(int, input().split()))
N=int(input())
a=[int(input()) for i in range(N)]
 
n=np.array([N_1,N_2,N_3])

for a_n in a:
    if a_n in n:
        n[n==a_n]=0
    else:
        pass
i=0


    
if np.all(n[0:,0]==0)==True:
    i=+1
    
elif np.all(n[0:,1]==0)==True:
    i+=1
    
elif np.all(n[0:,2]==0)==True:
    i+=1
    
elif np.all(n[0,0:]==0)==True:
    i+=1
    
elif np.all(n[1,0:]==0)==True:
    i+=1
    
elif np.all(n[2,0:]==0)==True:
    i+=1
    
elif n[0,0] and n[1,1] and n[2,2] ==0:
    i+=1

elif n[0,2] and n[1,1] and n[2,0] ==0:
    i+=1

if i>0:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
import numpy as np
N_1=list(map(int, input().split()))
N_2=list(map(int, input().split()))
N_3=list(map(int, input().split()))
N=int(input())
a=[int(input()) for i in range(N)]

n=np.array([N_1,N_2,N_3])


for a_n in a:
    if a_n in n:
        n[n==a_n]=0
    else:
        pass
i=0

print(n)
    
if np.all(n[0:,0]==0):
    i=+1
    
elif np.all(n[0:,1]==0):
    i+=1
    
elif np.all(n[0:,2]==0):
    i+=1
    
elif np.all(n[0,0:]==0):
    i+=1
    
elif np.all(n[1,0:]==0):
    i+=1
    
elif np.all(n[2,0:]==0):
    i+=1
    
elif n[0,0] and n[1,1] and n[2,2] ==0:
    i+=1

elif n[0,2] and n[1,1] and n[2,0] ==0:
    i+=1

if i>0:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
import numpy as np
N_1=list(map(int, input().split()))
N_2=list(map(int, input().split()))
N_3=list(map(int, input().split()))
N=int(input())
a=[int(input()) for i in range(N)]

n=np.array([N_1,N_2,N_3])


for a_n in a:
    if a_n in n:
        n[n==a_n]=0
    else:
        pass
i=0
   
    
if np.all(n[0:,0])==0:
    i=+1
elif np.all(n[0:,1])==0:
    i+=1
elif np.all(n[0:,2])==0:
    i+=1
elif np.all(n[0,0:])==0:
    i+=1
elif np.all(n[1,0:])==0:
    i+=1                
elif np.all(n[2,0:])==0:
    i+=1                
elif n[0,0] and n[1,1] and n[2,2] ==0:
    i+=1                
elif n[0,2] and n[1,1] and n[2,0] ==0:
    i+=1
 
if i>0:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:

def check(grid):
	bingo=False
	#row
	for i in range(3):
		count=0
		for j in range(3):
			if grid[i][j]==1:
				count+=1
	if count==3:
		bingo=True
	#col
	for i in range(3):
		count=0
		for j in range(3):
			if grid[j][i]==1:
				count+=1
	if count==3:
		bingo=True
	#left diag
	count=0
	for i in range(3):
		if grid[i][i]==1:
			count+=1
	if count==3:
		bingo=True
	#right diag
	count=0
	for i in range(3):
		if grid[i][2-i]==1:
			count+=1
	if count==3:
		bingo=True
		
	return bingo
		
pos={}
for i in range(3):
	temp=list(map(int,input().split(' ')))
	for j,t in enumerate(temp):
		pos[t]=[i,j]
grid=[[0 for i in range(3)] for j in range(3)]

n=int(input())
for i in range(n):
	t=int(input())
	if t in pos.keys():
		r,c=pos[t]
		grid[r][c]=1
bingo=check(grid)

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

Submission status: Wrong Answer

Solution code:

def check(grid):
	bingo=False
	#row
	for i in range(3):
		count=0
		for j in range(3):
			if grid[i][j]==1:
				count+=1
	if count==3:
		print(1)
		bingo=True
	#col
	count=0
	for i in range(3):
		for j in range(3):
			if grid[j][i]==1:
				count+=1
	if count==3:
		print(2)
		bingo=True
	#left diag
	count=0
	for i in range(3):
		if grid[i][i]==1:
			count+=1
	if count==3:
		print(3)
		bingo=True
	#right diag
	count=0
	for i in range(3):
		if grid[i][2-i]==1:
			count+=1
	if count==3:
		print(4)
		bingo=True
		
	return bingo
		
pos={}
for i in range(3):
	temp=list(map(int,input().split(' ')))
	for j,t in enumerate(temp):
		pos[t]=[i,j]
grid=[[0 for i in range(3)] for j in range(3)]

n=int(input())
for i in range(n):
	t=int(input())
	if t in pos.keys():
		r,c=pos[t]
		grid[r][c]=1
bingo=check(grid)

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

Submission status: Wrong Answer

Solution code:

def check(grid):
	bingo=False
	#row
	for i in range(3):
		count=0
		for j in range(3):
			if grid[i][j]==1:
				count+=1
	if count==3:
		bingo=True
	#col
	count=0
	for i in range(3):
		for j in range(3):
			if grid[j][i]==1:
				count+=1
	if count==3:
		bingo=True
	#left diag
	count=0
	for i in range(3):
		for j in range(3):
			if grid[i][i]==1:
				count+=1
	if count==3:
		bingo=True
	#right diag
	count=0
	for i in range(3):
		for j in range(3):
			if grid[i][2-i]==1:
				count+=1
	if count==3:
		bingo=True
		
	return bingo
		
pos={}
for i in range(3):
	temp=list(map(int,input().split(' ')))
	for j,t in enumerate(temp):
		pos[t]=[i,j]
grid=[[0 for i in range(3)] for j in range(3)]

n=int(input())
for i in range(n):
	t=int(input())
	if t in pos.keys():
		r,c=pos[t]
		grid[r][c]=1
bingo=check(grid)
if bingo:
	print("Yes")
else:
	print("No")

Submission status: Wrong Answer

Solution code:

def check(grid):
	bingo=False
	#row
	for i in range(3):
		count=0
		for j in range(3):
			if grid[i][j]==1:
				count+=1
	if count==3:
		bingo=True
	#col
	for i in range(3):
		count=0
		for j in range(3):
			if grid[j][i]==1:
				count+=1
	if count==3:
		bingo=True
	#left diag
	for i in range(3):
		count=0
		for j in range(3):
			if grid[i][i]==1:
				count+=1
	if count==3:
		bingo=True
	#right diag
	for i in range(3):
		count=0
		for j in range(3):
			if grid[2-i][2-i]==1:
				count+=1
	if count==3:
		bingo=True
		
	return bingo
		
pos={}
for i in range(3):
	temp=list(map(int,input().split(' ')))
	for j,t in enumerate(temp):
		pos[t]=[i,j]
grid=[[0 for i in range(3)] for j in range(3)]

n=int(input())
for i in range(n):
	t=int(input())
	if t in pos.keys():
		r,c=pos[t]
		grid[r][c]=1
bingo=check(grid)
if bingo:
	print("Yes")
else:
	print("No")

Submission status: Wrong Answer

Solution code:

def check(grid):
	bingo=False
	#row
	for i in range(3):
		count=0
		for j in range(3):
			if grid[i][j]==1:
				count+=1
	if count==3:
		bingo=True
	#col
	for i in range(3):
		count=0
		for j in range(3):
			if grid[j][i]==1:
				count+=1
	if count==3:
		bingo=True
	#left diag
	for i in range(3):
		count=0
		for j in range(3):
			if grid[i][i]==1:
				count+=1
	if count==3:
		bingo=True
	#right diag
	for i in range(3):
		count=0
		for j in range(3):
			if grid[2-i][2-i]==1:
				count+=1
	if count==3:
		bingo=True
		
	return bingo
		
pos={}
for i in range(3):
	temp=list(map(int,input().split(' ')))
	for j,t in enumerate(temp):
		pos[t]=[i,j]
grid=[[0 for i in range(3)] for j in range(3)]

n=int(input())
bingo=False
for i in range(n):
	t=int(input())
	if t in pos.keys():
		r,c=pos[t]
		grid[r][c]=1
		if not bingo:
			bingo=check(grid)
if bingo:
	print("Yes")
else:
	print("No")

Submission status: Wrong Answer

Solution code:
def main():
    A = [list(map(int, input().split())) for _ in range(3)]
    n = int(input())
    b = [int(input()) for _ in range(n)]
    # print("A: {}".format(A))
    # print("n: {}".format(n))
    # print("b: {}".format(b))
    outs = [[False for _ in range(3)] for _ in range(3)]
    is_bingo = False
    for i in range(3):
        for j in range(3):
            outs[i][j] = A[i][j] in b
    
    # check row
    for i in range(3):
        is_bingo = outs[i][:] == [True for _ in range(3)]
        if is_bingo:
            return "Yes"

    # check column
    for i in range(3):
        is_bingo = outs[:][i] == [True for _ in range(3)]
        if is_bingo:
            return "Yes"
    # check x
    is_bingo = [outs[i][i] for i in range(3)] == [True for _ in range(3)]
    if is_bingo:
        return "Yes"
    is_bingo = [outs[i][-i-1] for i in range(3)] == [True for _ in range(3)]
    if is_bingo:
        return "Yes"
    return "No"

if __name__ == "__main__":
    print(main())

Submission status: Wrong Answer

Solution code:
a = [ list(map(int,input().split())) for i in range(3)]    # 二重リスト（配列）に標準入力　
n = int(input())                                           # 標準入力（整数）
d = [[0 for i in range(3)] for j in range(3)]              # 要素が全て0の３×３の二重リスト（配列）

for k in range(n):              #  n回繰り返す
    b = int(input())            #　標準入力（整数）
    for i in range(3):          
        for j in range(3):
            if a[i][j] == b:    #  aに、bと同じ数字があるか見る
                d[i][j] = 1     #　あれば、対応するdに1を代入

ans = 'No'                      #  最初はNoと仮定
count = 0

# 横がビンゴか確認
for i in range(3):
    if ans == 'Yes':            # YesかNoか確認
        break;                  # Yesならばループを抜ける
    count = 0
    for j in range(3):
        count += d[i][j]
        if count == 3:          # １行で3つ１があるか確認
            ans == 'Yes'        # あればビンゴなので'Yes'

# 縦がビンゴか確認
for i in range(3):
    if ans == 'Yes':            # YesかNoか確認
        break;                  # Yesならばループを抜ける
    count = 0
    for j in range(3):
        count += d[j][i]
        if count == 3:          # １行で3つ１があるか確認
            ans == 'Yes'        # あればビンゴなので'Yes'


# 左上から右下にかけて斜めにビンゴしているか確認
count = 0
for i in range(3):
    if ans == 'Yes':
        break;
    count += d[i][i]
    if count == 3:
        ans = 'Yes'

#右上から左下にかけて斜めにビンゴしているか確認
count = 0
for i in range(3):
    if ans == 'Yes':
        break;
    count += d[i][2 - i]
    if count == 3:
        ans = 'Yes'
            

print(ans)

Submission status: Wrong Answer

Solution code:
a = [ list(map(int,input().split())) for i in range(3)]    # 二重リスト（配列）に標準入力　
n = int(input())                                           # 標準入力（整数）
d = [[0 for i in range(3)] for j in range(3)]              # 要素が全て0の３×３の二重リスト（配列）

for k in range(n):              #  n回繰り返す
    b = int(input())            #　標準入力（整数）
    for i in range(3):          
        for j in range(3):
            if a[i][j] == b:    #  aに、bと同じ数字があるか見る
                d[i][j] = 1     #　あれば、対応するdに1を代入

ans = 'No'                      #  最初はNoと仮定
count = 0

# 横がビンゴか確認
for i in range(3):
    if count == 3:              # １行で3つ１があるか確認
        ans = 'Yes'             # あればビンゴなので'Yes'
        break;                  # ループを抜ける
    count = 0
    for j in range(3):
        count += d[i][j]

# 縦がビンゴか確認
for i in range(3):
    if count == 3:
        ans = 'Yes' 
        break;
    count = 0
    for j in range(3):
        count += d[j][i]

# 左上から右下にかけて斜めにビンゴしているか確認
count = 0
for i in range(3):
    if ans == 'Yes':
        break;
    count += d[i][i]
    if count == 3:
        ans = 'Yes'

#右上から左下にかけて斜めにビンゴしているか確認
count = 0
for i in range(3):
    if ans == 'Yes':
        break;
    count += d[i][2 - i]
    if count == 3:
        ans = 'Yes'
            

print(ans)

Submission status: Wrong Answer

Solution code:
A = []

for i in range(3):
    val = list(map(int, input().split()))
    A.append(val)

N = int(input())

b = [int(input()) for i in range(N)]


#斜めがビンゴになる場合
if A[0][0] in b and A[1][1] in b and A[2][2] in b or A[0][2] in b and A[1][1] in b and A[2][0] in b:
    print("Yes")
else:
    for i in range(3):
        #横がビンゴになる場合
        if A[i][0] in b and A[i][1] in b and A[i][2] in b:
            print("Yes")
            break

        #縦がビンゴになる場合
        elif A[0][i] in b and A[1][i] in b and A[2][i] in b:
            print("Yes")
            break

        #ビンゴがない場合
        else:
            print("No")
            break

Submission status: Wrong Answer

Solution code:
A = []

for i in range(3):
    val = list(map(int, input().split()))
    A.append(val)

N = int(input())

b = [int(input()) for i in range(N)]

for i in range(3):
    #横がビンゴになる場合
    if A[i][0] in b and A[i][1] in b and A[i][2] in b:
        print("Yes")
        break

    #縦がビンゴになる場合
    elif A[0][i] in b and A[1][i] in b and A[2][i] in b:
        print("Yes")
        break

    #斜めがビンゴになる場合
    elif A[0][0] in b and A[1][1] in b and A[2][2] in b or A[0][2] in b and A[1][1] in b and A[2][0] in b:
        print("Yes")
        break
    
    #ビンゴがない場合
    else:
        print("No")
        break

Submission status: Wrong Answer

Solution code:
a = [ list(map(int,input().split())) for i in range(3)]    # 二重リスト（配列）に標準入力　
n = int(input())                                           # 標準入力（整数）
d = [[0 for i in range(3)] for j in range(3)]              # 要素が全て0の３×３の二重リスト（配列）

for k in range(n):              #  n回繰り返す
    b = int(input())            #　標準入力（整数）
    for i in range(3):          
        for j in range(3):
            if a[i][j] == b:    #  aに、bと同じ数字があるか見る
                d[i][j] = 1     #　あれば、対応するdに1を代入

ans = 'No'                      #  最初はNoと仮定
count = 0

# 横がビンゴか確認
for i in range(3):
    if count == 3:              # １行で3つ１があるか確認
        ans = 'Yes'         # あればビンゴなので'Yes'
        break;              # 内側のループを抜ける
    count = 0
    for j in range(3):
        count += d[i][j]

# 縦がビンゴか確認
count = 0
for i in range(3):
    if ans == 'Yes': 
        break;
    count = 0
    for j in range(3):
        count += d[j][i]
        if count == 3:
            ans = 'Yes'

# 左上から右下にかけて斜めにビンゴしているか確認
count = 0
for i in range(3):
    if ans == 'Yes':
        break;
    count += d[i][i]
    if count == 3:
        ans = 'Yes'

#右上から左下にかけて斜めにビンゴしているか確認
count = 0
for i in range(3):
    if ans == 'Yes':
        break;
    count += d[i][2 - i]
    if count == 3:
        ans = 'Yes'
            

print(ans)

Submission status: Wrong Answer

Solution code:
a = [ list(map(int,input().split())) for i in range(3)]    # 二重リスト（配列）に標準入力　
n = int(input())                                           # 標準入力（整数）
d = [[0 for i in range(3)] for j in range(3)]              # 要素が全て0の３×３の二重リスト（配列）

for k in range(n):              #  n回繰り返す
    b = int(input())            #　標準入力（整数）
    for i in range(3):          
        for j in range(3):
            if a[i][j] == b:    #  aに、bと同じ数字があるか見る
                d[i][j] = 1     #　あれば、対応するdに1を代入

ans = 'No'                      #  最初はNoと仮定
count = 0

# 横がビンゴか確認
for i in range(3):
    if count == 3:              # １行で3つ１があるか確認
            ans = 'Yes'         # あればビンゴなので'Yes'
            break;              # 内側のループを抜ける
    count = 0
    for j in range(3):
        count += d[i][j]

# 縦がビンゴか確認
count = 0
for i in range(3):
    if ans == 'Yes' or count == 3: 
        break;
    count = 0
    for j in range(3):
        count += d[j][i]
    if count == 3:
        ans = 'Yes'

# 左上から右下にかけて斜めにビンゴしているか確認
count = 0
for i in range(3):
    if ans == 'Yes':
        break;
    count += d[i][i]
    if count == 3:
        ans = 'Yes'

#右上から左下にかけて斜めにビンゴしているか確認
count = 0
for i in range(3):
    if ans == 'Yes':
        break;
    count += d[i][2 - i]
    if count == 3:
        ans = 'Yes'
            

print(ans)

Submission status: Wrong Answer

Solution code:
a1=[map(int(),input().split())]
a2=[map(int(),input().split())]
a3=[map(int(),input().split())]
n=int(input())
b=[input() for i in range(n)]

line1=[]
line2=[]
line3=[]

for num in b:
    if num in a1:
        line1.append(a1.index(num))
    elif num in a2:
        line2.append(a2.index(num))
    elif num in a3:
        line3.append(a3.index(num))
if 0 in line1 and 0 in line2 and 0 in line3 or 1 in line1 and 1 in line2 and 1 in line3 or 2 in line1 and 2 in line2 and 2 in line3 :
    print("Yes")
elif 0 in line1 and 1 in line2 and 2 in line3 or 2 in line1 and 1 in line2 and 0 in line3:
    print("Yes")
elif 0 in line1 and 1 in line1 and 2 in line1 or 0 in line2 and 1 in line2 and 2 in line2 or 0 in line3 and 1 in line3 and 2 in line3:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
a = []
for i in range(3):
  inp = [int(x) for x in input().split()]
  a.append(inp)
n = int(input())
b = []
for i in range(n):
  b.append(int(input()))
for i in range(n):
  for j in range(3):
    for k in range(3):
      if a[j][k] == b[i]:
        a[j][k] = 0
if a[0][0] == 0 and a[0][1] == 0 and a[0][2] == 0:
  print('Yes')
elif a[1][0] == 0 and a[1][1] == 0 and a[1][2] == 0:
  print('Yes')
elif a[1][0] == 0 and a[1][1] == 0 and a[1][2] == 0:
  print('Yes')
    
elif a[0][0] == 0 and a[1][0] == 0 and a[2][0] == 0:
  print('Yes')
elif a[0][1] == 0 and a[1][1] == 0 and a[2][1] == 0:
  print('Yes')
elif a[0][2] == 0 and a[1][2] == 0 and a[2][2] == 0:
  print('Yes')
    
elif a[0][0] == 0 and a[1][1] == 0 and a[2][2] == 0:
  print('Yes')
elif a[0][2] == 0 and a[1][1] == 0 and a[2][0] == 0:
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

Solution code:
a = []
for i in range(3):
  inp = [int(x) for x in input().split()]
  a.append(inp)
n = int(input())
b = []
for i in range(n):
  b.append(int(input()))
for i in range(n):
  for j in range(3):
    for k in range(3):
      if a[j][k] == b[i]:
        a[j][k] = 0
if a[0][0] == 0 and a[0][1] == 0 and a[0][2] == 0:
  print('YES')
elif a[1][0] == 0 and a[1][1] == 0 and a[1][2] == 0:
  print('YES')
elif a[1][0] == 0 and a[1][1] == 0 and a[1][2] == 0:
  print('YES')
    
elif a[0][0] == 0 and a[1][0] == 0 and a[2][0] == 0:
  print('YES')
elif a[0][1] == 0 and a[1][1] == 0 and a[2][1] == 0:
  print('YES')
elif a[0][2] == 0 and a[1][2] == 0 and a[2][2] == 0:
  print('YES')
    
elif a[0][0] == 0 and a[1][1] == 0 and a[2][2] == 0:
  print('YES')
elif a[0][2] == 0 and a[1][1] == 0 and a[2][0] == 0:
  print('YES')
else:
  print('NO')

Submission status: Wrong Answer

Solution code:

a1, a2, a3 = [input().split() for l in range(3)]
n = int(input())
b = [input() for i in range(n)]

var1 = []
var2 = []
var3 = []

for bb in b:
    if bb in a1:
        var1.append(a1.index(bb))

    elif bb in a2:
        var2.append(a2.index(bb))
    elif bb in a3:
        var3.append(a3.index(bb))

#たて
if 0 in var1 and 0 in var2 and 0 in var3 or 1 in var1 and 1 in var2 and 1 in var3 or 2 in var1 and 2 in var2 and 2 in var3 :
    print("Yes")

#よこ
elif 0 and 1 and 2 in var1 or  0 and 1 and 2 in var2 or  0 and 1 and 2 in var3 :
    print("Yes")

#ななめ
elif 0 in var1 and 1 in var2 and 2 in var3 or 2 in var1 and 1 in var2 and 0 in var3:
    print("Yes")

else : 
    print("No")

Submission status: Wrong Answer

Solution code:

a = []
for i in range(3):
  inp = [int(x) for x in input().split()]
  a.append(inp)
n = int(input())
b = []
for i in range(n):
  b.append(input())
for i in range(n):
  for j in range(3):
    for k in range(3):
      if a[j][k] == b[i]:
        a[j][k] = 0
if a[0][0] == 0 and a[0][1] == 0 and a[0][2] == 0:
  print('YES')
elif a[1][0] == 0 and a[1][1] == 0 and a[1][2] == 0:
  print('YES')
elif a[1][0] == 0 and a[1][1] == 0 and a[1][2] == 0:
  print('YES')
    
elif a[0][0] == 0 and a[1][0] == 0 and a[2][0] == 0:
  print('YES')
elif a[0][1] == 0 and a[1][1] == 0 and a[2][1] == 0:
  print('YES')
elif a[0][2] == 0 and a[1][2] == 0 and a[2][2] == 0:
  print('YES')
    
elif a[0][0] == 0 and a[1][1] == 0 and a[2][2] == 0:
  print('YES')
elif a[0][2] == 0 and a[1][1] == 0 and a[2][0] == 0:
  print('YES')
else:
  print('NO')

Submission status: Wrong Answer

Solution code:
mat=[]

for i in range(3):
    inp = [int(x) for x in input().split()]
    mat.append(inp)
    
n = int(input())

for _ in range(n):
    q = int(input())
    for i in range(3):
        if q in mat[i]:
            ind = mat[i].index(q)
            mat[i][ind] = '1'
            break
    
if mat[0][0]=='1' and mat[0][1]=='1' and mat[0][2]=='1':
    print('YES')
    
elif mat[1][0]=='1' and mat[1][1]=='1' and mat[1][2]=='1':
    print('YES')

elif mat[2][0]=='1' and mat[2][1]=='1' and mat[2][2]=='1':
    print('YES')

#col
elif mat[0][0]=='1' and mat[1][0]=='1' and mat[2][0]=='1':
    print('YES')

elif mat[0][1]=='1' and mat[1][1]=='1' and mat[2][1]=='1':
    print('YES')

elif mat[0][2]=='1' and mat[1][2]=='1' and mat[2][2]=='1':
    print('YES')

#diag
elif mat[0][0]=='1' and mat[1][1]=='1' and mat[2][2]=='1':
    print('YES')

elif mat[0][2]=='1' and mat[1][1]=='1' and mat[2][0]=='1':
    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 i in range(n)]
ai = [[1]*3 for _ in range(3)]
for i in range(3):
    for j in range(3):
        if a[i][j] in b:
            ai[i][j] = 0
ans = "No"
for k in range(3):
    if sum(ai[k])== 0:
        ans = "Yes"
for l in range(3):
    if ai[0][k]+ai[1][k]+ai[2][k] == 0:
        ans = "Yes"
if ai[0][0]+ai[1][1]+ai[2][2] == 0 or ai[0][2]+ai[2][0]+ai[1][1] == 0:
    ans = "Yes"
print(ans)

Submission status: Wrong Answer

Solution code:
def isBingo(a):
    for i in range(3):
        if a[i][0] == a[i][1] and a[i][0] == a[i][2] and a[i][0] == -1:
            return 'Yes'
        elif a[0][i] == a[1][i] and a[i][0] == a[2][i] and a[0][i] == -1:
            return 'Yes'
    if a[0][0] == a[1][1] and a[0][0] == a[2][2] and a[0][0] == -1:
        return 'Yes'
    elif a[0][2] == a[1][1] and a[0][2] == a[2][0] and a[0][2] == -1:
        return 'Yes'
    else:
        return 'No'
    
a = []
for i in range(3):
    a.append(list(map(int, input().split())))
n = int(input())
b = []
for i in range(n):
    b.append(int(input()))

for i in range(n):
    for j in range(3):
        if b[i] in a[j]:
            a[j][a[j].index(b[i])] = -1

print(isBingo(a))

Submission status: Wrong Answer

Solution code:
def isBingo(a):
    for i in range(3):
        if a[i][0] == a[i][1] and a[i][0] == a[i][2] and a[i][0] == -1:
            return 'Yes'
        elif a[0][i] == a[1][i] and a[i][0] == a[2][i] and a[i][0] == -1:
            return 'Yes'
    if a[0][0] == a[1][1] and a[0][0] == a[2][2] and a[i][0] == -1:
        return 'Yes'
    elif a[0][2] == a[1][1] and a[0][2] == a[2][0] and a[i][0] == -1:
        return 'Yes'
    else:
        return 'No'
    
a = []
for i in range(3):
    a.append(list(map(int, input().split())))
n = int(input())
b = []
for i in range(n):
    b.append(int(input()))

for i in range(n):
    for j in range(3):
        if b[i] in a[j]:
            a[j][a[j].index(b[i])] = -1

print(isBingo(a))

Submission status: Wrong Answer

Solution code:
def isBingo(a):
    for i in range(3):
        if a[i][0] == a[i][1] and a[i][0] == a[i][2]:
            return 'Yes'
        elif a[0][i] == a[1][i] and a[i][0] == a[2][i]:
            return 'Yes'
    if a[0][0] == a[1][1] and a[0][0] == a[2][2]:
        return 'Yes'
    elif a[0][2] == a[1][1] and a[0][2] == a[2][0]:
        return 'Yes'
    else:
        return 'No'
    
a = []
for i in range(3):
    a.append(list(map(int, input().split())))
n = int(input())
b = []
for i in range(n):
    b.append(int(input()))

for i in range(n):
    for j in range(3):
        if b[i] in a[j]:
            a[j][a[j].index(b[i])] = -1

print(isBingo(a))