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:
As = [list(map(int, input().split())) for x in range(3)]
N = int(input())
bs = [int(input()) for x in range(N)]


def create_bingo_card():
  result = [[0, 0, 0] for x in range(3)]
  i = 0
  while True:
    i2 = 0
    while True:
      if bs[i2] in As[i]:
        result[i][As[i].index(bs[i2])] += 1
      i2 += 1
      if i2 == len(bs):
        break
    i += 1
    if i == len(As):
      break
  return result


def solvd(bingo):
  tmp = [bingo[0][0], bingo[1][1], bingo[2][2]]
  if check1(tmp):
    print("Yes")
    return

  tmp = [bingo[0][2], bingo[1][1], bingo[2][0]]
  if check1(tmp):
    print("Yes")
    return

  r = 0
  for x in range(3):
    tmp = [bingo[0][x], bingo[1][x], bingo[2][x]]
    if check1(tmp):
      print("Yes")
      return

    bingoSet = set(bingo[x])
    if check2(bingoSet):
      r += 1

  if r == 3:
    print("Yes")
    return
  print("No")


def check1(s):
  return s.count(1) == 3


def check2(s):
  return not (0 in list(s))


def main():
  Cs = create_bingo_card()
  solvd(Cs)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import numpy as np

def in1d(ar1, ar2, assume_unique=False, invert=False):
    # Ravel both arrays, behavior for the first array could be different
    ar1 = np.asarray(ar1).ravel()
    ar2 = np.asarray(ar2).ravel()

    # Check if one of the arrays may contain arbitrary objects
    contains_object = ar1.dtype.hasobject or ar2.dtype.hasobject

    # This code is run when
    # a) the first condition is true, making the code significantly faster
    # b) the second condition is true (i.e. `ar1` or `ar2` may contain
    #    arbitrary objects), since then sorting is not guaranteed to work
    if len(ar2) < 10 * len(ar1) ** 0.145 or contains_object:
        if invert:
            mask = np.ones(len(ar1), dtype=bool)
            for a in ar2:
                mask &= (ar1 != a)
        else:
            mask = np.zeros(len(ar1), dtype=bool)
            for a in ar2:
                mask |= (ar1 == a)
        return mask

    # Otherwise use sorting
    if not assume_unique:
        ar1, rev_idx = np.unique(ar1, return_inverse=True)
        ar2 = np.unique(ar2)

    ar = np.concatenate((ar1, ar2))
    # We need this to be a stable sort, so always use 'mergesort'
    # here. The values from the first array should always come before
    # the values from the second array.
    order = ar.argsort(kind='mergesort')
    sar = ar[order]
    if invert:
        bool_ar = (sar[1:] != sar[:-1])
    else:
        bool_ar = (sar[1:] == sar[:-1])
    flag = np.concatenate((bool_ar, [invert]))
    ret = np.empty(ar.shape, dtype=bool)
    ret[order] = flag

    if assume_unique:
        return ret[:len(ar1)]
    else:
        return ret[rev_idx]

def isin(element, test_elements, assume_unique=False, invert=False):
    element = np.asarray(element)
    return in1d(element, test_elements, assume_unique=assume_unique,
                invert=invert).reshape(element.shape)
A = []
for i in range(3):
    A.append(list(map(int, input().split())))
A = np.array(A)

N = int(input())
b = np.zeros(N, dtype=np.int)
for i in range(N):
    b[i] = int(input())
T = isin(A,b)
ans=[0,0,0,0]
ans[0]=T.all(axis=0).all()
ans[1]=T.all(axis=1).all()
ans[2]=np.diag(T).all()
ans[3]=np.diag(T[:,[2,1,0]]).all()
if any(ans):
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

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

N = int(input())
b = []

for i in range(N):
  b.append(int(input()))

match = ''

for star in b:
  for i, item in enumerate(A):
    if item == star:
      match += str(i)

match = sorted(match)
match = ''.join(match)

if '012' in match:
  print('Yes')
elif '345' in match:
  print('Yes')
elif '678' in match:
  print('Yes')
elif '0' in match:
  if '3' in match:
    if '6' in match:
      print('Yes')
  if '4' in match:
    if '8' in match:
      print('Yes')
elif '1' in match:
  if '4' in match:
    if '7' in match:
      print('Yes')
elif '2' in match:
  if '4' in match:
    if '6' in match:
      print('Yes')
  if '5' in match:
    if '8' in match:
      print('Yes')
else:
  print('No')

Submission status: Wrong Answer

Solution code:
rows = []
for i in range(3):
    row = [int(x) for x in input().split()]
    rows.append(row)


columns = []
for k in range(3):
    column = [rows[l][k] for l in range(3)]
    columns.append(column)

left = []
for m in range(3):
    left.append(rows[m][m])

right = []
for n in range(3):
    for o in range(3)[::-1]:
        right.append(rows[n][o])

N = int(input())
choice = []
for j in range(N):
    choice.append(int(input()))


matches = []
for row in rows:
    matches.append([c for c in row if c in choice])

for column in columns:
    matches.append([c for c in column if c in choice])

matches.append([c for c in left if c in choice])
matches.append([c for c in right if c in choice])


isPrinted = False
for match in matches:
    if (len(match) == 3):
        print("Yes")
        isPrinted = True
        break

if (not isPrinted):
    print("No")

Submission status: Wrong Answer

Solution code:
x = list(map(int, input().split()))
y = list(map(int, input().split()))
z = list(map(int, input().split()))
d=x+y+z
nalist=[]
N=int(input())
for i in range(N):
    na = int(input())
    nalist.append(na)

for i in nalist:
    if i in d:
        counter=d.index(i)
        d[counter]=101

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

Submission status: Wrong Answer

Solution code:
a_list = list(map(int, input().split()))
b_list = list(map(int, input().split()))
c_list = list(map(int, input().split()))
N = int(input())
d_list = [int(input()) for k in range(N)]

for n in range(3):
    for p in range(3):
        if d_list[n] == a_list[p]:
            a_list[p] = 555
    for q in range(3):
        if d_list[n] == b_list[q]:
            b_list[q] = 555
    for r in range(3):
        if d_list[n] == c_list[r]:
            c_list[r] = 555

if a_list[0] == a_list[1] == a_list[2]:
    print('Yes')

elif b_list[0] == b_list[1] == b_list[2]:
    print('Yes')

elif c_list[0] == c_list[1] == c_list[2]:
    print('Yes')

elif a_list[0] == b_list[0] == c_list[0]:
        print('Yes')
elif a_list[1] == b_list[1] == c_list[1]:
        print('Yes')
elif a_list[2] == b_list[2] == c_list[2]:
    print('Yes')
elif a_list[0] == b_list[1] == c_list[2]:
    print('Yes')

elif a_list[2] == b_list[1] == c_list[0]:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
l = []
flag = 0
for i in range(3):
  for j in input().split():
    l.append(j)
n = int(input())
for i in range(n):
  a = input()
  if a in l:
    l[l.index(a)] = 0
if l[0:3] == 0 or l[3:6] == 0 or l[6:9] == 0:
  flag = 1
if l[0::3] == 0 or l[1::3] == 0 or l[2::3] == 0:
  flag = 1
if l[0::4] == 0 or l[2::2] == 0:
  flag = 1
if flag:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
As = [list(map(int, input().split())) for x in range(3)]
N = int(input())
bs = [int(input()) for x in range(N)]


def create_bingo_card():
  result = [[0, 0, 0] for x in range(3)]
  i = 0
  while True:
    i2 = 0
    while True:
      if bs[i2] in As[i]:
        result[i][As[i].index(bs[i2])] += 1
      i2 += 1
      if i2 == len(bs):
        break
    i += 1
    if i == len(As):
      break
  return result


def solvd(bingo):
  tmp = [bingo[0][0], bingo[1][1], bingo[2][2]]
  if check1(tmp):
    print("Yes")
    return

  tmp = [bingo[0][2], bingo[1][1], bingo[2][0]]
  if check1(tmp):
    print("Yes")
    return

  r = 0
  for x in range(3):
    tmp = [bingo[0][x], bingo[1][x], bingo[2][x]]
    if check1(tmp):
      print("Yes")
      return

    bingoSet = set(bingo[x])
    if check2(bingoSet):
      r += 1

  if r == 3:
    print("Yes")
    return
  print("No")


def check1(s):
  return s.count(1) == 3


def check2(s):
  return not (0 in list(s))


def main():
  Cs = create_bingo_card()
  print(Cs)
  solvd(Cs)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
l = [list(map(int,input().split())) for _ in range(3)]
lb = [[0 for j in range(3)] for i in range(3)]
bl = []
cnt = 0
f = 0

# print(l)
# print(lb)

n = int(input())

for i in range(n):
    bl.append(int(input()))

bll = list(dict.fromkeys(bl))
# print(bll)

for i in bll:
    for j in range(3):
        for k in range(3):
            if l[j][k] == int(i):
                # print('hit')
                lb[j][k] = 1
                break

# print(lb)

for i in range(3):
    for j in range(3):
        if lb[i][j] == 1:
            cnt += 1
        else:
            cnt = 0
            break
    else:
        if cnt == 3:
            f = 1
            break
        else:
            cnt = 0

cnt = 0

for i in range(3):
    for j in range(3):
        if lb[j][i] == 1:
            cnt += 1
        else:
            cnt = 0
            break
    else:
        if cnt == 3:
            f = 1
            break
        else:
            cnt = 0

if lb[0][0] == 1 and lb[1][1] == 1 and lb[2][2] == 1:
    f = 1
elif lb[2][2] == 1 and lb[1][1] == 1 and lb[0][0] == 1:
    f = 1

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

Submission status: Wrong Answer

Solution code:
import numpy as np

def in1d(ar1, ar2, assume_unique=False, invert=False):
    # Ravel both arrays, behavior for the first array could be different
    ar1 = np.asarray(ar1).ravel()
    ar2 = np.asarray(ar2).ravel()

    # Check if one of the arrays may contain arbitrary objects
    contains_object = ar1.dtype.hasobject or ar2.dtype.hasobject

    # This code is run when
    # a) the first condition is true, making the code significantly faster
    # b) the second condition is true (i.e. `ar1` or `ar2` may contain
    #    arbitrary objects), since then sorting is not guaranteed to work
    if len(ar2) < 10 * len(ar1) ** 0.145 or contains_object:
        if invert:
            mask = np.ones(len(ar1), dtype=bool)
            for a in ar2:
                mask &= (ar1 != a)
        else:
            mask = np.zeros(len(ar1), dtype=bool)
            for a in ar2:
                mask |= (ar1 == a)
        return mask

    # Otherwise use sorting
    if not assume_unique:
        ar1, rev_idx = np.unique(ar1, return_inverse=True)
        ar2 = np.unique(ar2)

    ar = np.concatenate((ar1, ar2))
    # We need this to be a stable sort, so always use 'mergesort'
    # here. The values from the first array should always come before
    # the values from the second array.
    order = ar.argsort(kind='mergesort')
    sar = ar[order]
    if invert:
        bool_ar = (sar[1:] != sar[:-1])
    else:
        bool_ar = (sar[1:] == sar[:-1])
    flag = np.concatenate((bool_ar, [invert]))
    ret = np.empty(ar.shape, dtype=bool)
    ret[order] = flag

    if assume_unique:
        return ret[:len(ar1)]
    else:
        return ret[rev_idx]

def isin(element, test_elements, assume_unique=False, invert=False):
    element = np.asarray(element)
    return in1d(element, test_elements, assume_unique=assume_unique,
                invert=invert).reshape(element.shape)
A = []
for i in range(3):
    A.append(list(map(int, input().split())))
A = np.array(A)

N = int(input())
b = np.zeros(N, dtype=np.int)
for i in range(N):
    b[i] = int(input())
T = isin(A,b)
print(T)
ans=[0,0,0,0]
ans[0]=T.all(axis=0).all()
ans[1]=T.all(axis=1).all()
ans[2]=np.diag(T).all()
ans[3]=np.diag(T[:,[2,1,0]]).all()
if any(ans):
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
a= list(map(int, input().split()))
b=list(map(int, input().split()))
c=list(map(int, input().split()))


count = int(input())

for num in range(count):
    x = int(input())
    for y in range(3):
        if a[y] == x:
            a[y] = 0
    for y in range(3):
        if b[y] == x:
            b[y] = 0
    for y in range(3):
        if c[y] == x:
            c[y] = 0

ans = 0
ans = a[0] * a[1] * a[2]
ans += b[0] * b[1] * b[2]
ans += c[0] * c[1] * c[2]
ans += a[0] * b[0] * c[0]
ans += a[1] * b[1] * c[1]
ans += a[2] * b[2] * c[2]

if ans == 0:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
a = list(map(int,input().split()))
aa = list(map(int,input().split()))
aaa = list(map(int,input().split()))
A = []
A.append(a)
A.append(aa)
A.append(aaa)
N = int(input())
b = []
for _ in range(N):
    b.append(int(input()))
c = []
ans = 0
if (A[0] in b) or (A[1] in b) or (A[2] in b):
    ans += 1
elif (A[0][0] in b) and (A[1][1] in b) and (A[2][2] in b):
    ans += 1
elif (A[0][2] in b) and (A[1][1] in b) and (A[2][0] in b):
    ans += 1
for i in range(3):
    for j in range(3):
        c.append(A[j][i])
    if c in b:
        ans += 1
if ans == 0:
    print("No")
else:
    print("Yes")

Submission status: Wrong Answer

Solution code:
def q2(data, num_list):
    data = [int(num) for d in data for num in d.split()]
    num_list = [int(n) for n in num_list]

    for num in num_list:
        data = [d if d != num else 0 for d in data]
        if check_bingo(data):
            return 'Yes'

    else:
        return 'No'


def check_bingo(data):
    # case1
    if sum(data[:3]) == 0: return True
    if sum(data[3:6]) == 0: return True
    if sum(data[6:]) == 0: return True
    if sum([data[0], data[3], data[6]]) == 0: return True
    if sum([data[i+1] for i in range(3)]) == 0: return True
    if sum([data[i + 2] for i in range(3)]) == 0: return True
    if sum([data[0], data[4], data[8]]) == 0: return True
    if sum([data[2], data[4], data[6]]) == 0: return True

    return False
  

data = [input() for _ in range(3)]

num = int(input())

num_list = [int(input()) for _ in range(num)]

print(q2(data, num_list))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
a = [[i for i in map(int, input().split())] for j in range(3)]
n = int(input())
ans = [[0]*3] * 3
for i  in range(n):
    b = int(input())
    for j in range(3):
        for k in range(3):
            if a[j][k] == b and a[j][k] != 1:
                ans[j][k] = 1
if ans[0][0] + ans[0][1] + ans[0][2] == 3 or ans[1][0] + ans[1][1] + ans[1][2] == 3 or ans[2][0] + ans[2][1] + ans[2][2] == 3 or ans[0][0] + ans[1][0] + ans[2][0] == 3 or ans[0][1] + ans[1][1] + ans[2][1] == 3 or ans[0][2] + ans[1][2] + ans[2][2] == 3 or ans[0][0] + ans[1][1] + ans[2][2] == 3 or ans[0][2] + ans[1][1] + ans[2][0] == 3:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

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

N = int(input())
b = []

for i in range(N):
  b.append(int(input()))

match = ''

for star in b:
  for i, item in enumerate(A):
    if item == star:
      match += str(i)

match = sorted(match)
match = ''.join(match)

print(match)

if '012' in match:
  print('Yes')
elif '345' in match:
  print('Yes')
elif '678' in match:
  print('Yes')
elif '0' in match:
  if '3' in match:
    if '6' in match:
      print('Yes')
  if '4' in match:
    if '8' in match:
      print('Yes')
elif '1' in match:
  if '4' in match:
    if '7' in match:
      print('Yes')
elif '2' in match:
  if '4' in match:
    if '6' in match:
      print('Yes')
  if '5' in match:
    if '8' in match:
      print('Yes')
else:
  print('No')

Submission status: Wrong Answer

Solution code:
bingo = [ input().split() for j in range(3)]
N = int(input())
b = []
for n in range(N):
	b.append(input())
count = 0
total = 0
p = 'No'
for x in range(N):
	for i in range(3):
		for j in range(3):
			count = count + 1
			if bingo[i][j] == b[x]:
				total = total + count
	count = 0
	if total == 6 or total == 12 or total == 15 or total == 18 or total == 24 or total == 33 or total == 36 or total == 27 or total == 30 or total == 39 or total == 31 or total == 25 or total == 32:
		p = 'Yes'
		break
print(p)

Submission status: Wrong Answer

Solution code:
import itertools
# ここを参考にした
# https://note.nkmk.me/python-list-index/

def my_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return default
Bingo_index=[]
master =[]
# 二次元リスト
Row = 3
List=[[int(j) for j in input().split()] for i in range(Row)]
# 一次元リスト
dim_List=list(itertools.chain.from_iterable(List))
# print(dim_List)

n = int(input())
# print(n)
Num=[int(input()) for i in range(n)]
# 入力処理ここまで
# print(Num)
# print(set(dim_List) & set(Num))
Common = list(set(dim_List) & set(Num))
# print(Common)
# https://teratail.com/questions/156336
# リストに要素をコピーする方法↑
for a in Common:
    Bingo_index.append(my_index(dim_List,a))
# print('Bingo_indexは')
# print(Bingo_index)
# print(sorted(Bingo_index))
if len(Bingo_index) == 0:
     print('No')
    # Bingo_indexにビンゴしてるdim_Listの要素のインデックスが入ってる
answer1 = len(list(set([0, 1, 2])&set(Bingo_index)))
answer2 = len(list(set([3, 4, 5])&set(Bingo_index)))
answer3 = len(list(set([6, 7, 8])&set(Bingo_index)))
answer4 = len(list(set([0, 4, 8])&set(Bingo_index)))
answer5 = len(list(set([0, 3, 6])&set(Bingo_index)))
answer6 = len(list(set([1, 4, 7])&set(Bingo_index)))
answer7 = len(list(set([2, 5, 8])&set(Bingo_index)))

# Bingo_indexの中身にとanswer1~7の組み合わせがあるかどうか調べる
# 全部のアンサーとandをとってどれかの長さが3の奴があればyes出力や
master.append(answer1)
master.append(answer2)
master.append(answer3)
master.append(answer4)
master.append(answer5)
master.append(answer6)
master.append(answer7)
# print(master)
for i in master:
    if i == 3:
        print('Yes')
        break

Submission status: Wrong Answer

Solution code:
n1 = list(map(int, input().split()))
n2 = list(map(int, input().split()))
n3 = list(map(int, input().split()))
arr = []
x = int(input())
z=0
for i in range(x):
    arr.append(int(input()))
    if arr[i] == n1[0] or arr[i] == n1[1] or arr[i] == n1[2] or arr[i] == n2[0] or arr[i] == n2[1] or arr[i] == n2[2] or arr[i] == n3[0] or arr[i] == n3[1] or arr[i] == n3[2]:
        z+=1
if z >= 3: print("Yes")
else: print("No")

Submission status: Wrong Answer

Solution code:
def hasTri(arrs):
    k = [arrs[0][0], arrs[1][1], arrs[2][2]]
    if not 0 in k:
        return True
    return False
def hascol(arrs):
    for i in range(3):
        k = [arrs[0][i], arrs[1][i], arrs[2][i]]
        if not 0 in k:
            return True
    return False
def hasrow(arrs):
    for i in arrs:
        arr = [x for x in i if x != 0]
        if len(arr)==3:
            return True
    return False
A = [[0,0,0],[0,0,0],[0,0,0]]
B = [[0,0,0],[0,0,0],[0,0,0]]
for i in range(3):
    A[i][0],A[i][1],A[i][2] = map(int, input().split())
N = int(input())
Al = [i for x in A for i in x]
have = []
for _ in range(N):
    a = int(input())
    if a in Al:
        have.append(a)
indexs = [[]]
for k in have:
    index = [[ix,iy] for ix, row in enumerate(A) for iy, j in enumerate(row) if j == k]
    if len(index[0]) == 2:
        indexs = indexs + index
        B[index[0][0]][index[0][1]] = k
if hasTri(B)or hasrow(B )or hascol(B):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
a,b,c =map(int,input().split())
d,e,f =map(int,input().split())
g,h,t=map(int,input().split())
N=input()
N= int(N)
z = [ input() for i in range(N)]
z =map(int,z)
if a and d and g in z or b and e and h in z or c and f and t in z or a and b and c in z or c and e and f in z or g and h and t in z or a and e and t in z or g and e and c in z:
  print('Yes')
else :
  print('No')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
a=list(map(int,input().split()))
b=len(a)
c=[a]
w=0
for i in range(b-1):
    c.append(list(map(int,input().split())))
N=int(input())
d=[]
o=0
for y in range(N):
    d.append(int(input()))
for n in d:
    for p in range(b):
        for j in range(b):
            if c[p][j]==n:
               c[p][j]=0
                
for t in c:
    for h in t:
        if c.count(0)==b:
            o=1
            break
    else:
        continue
    break
for v in range(b):
    w=0
    for k in c:
        if k[v]==0:
            w+=1
        if w==b:
            o=1
w=0
for ji in range(b):
    if c[ji][ji]==0:
        w+=1
    if w==b:
        o=1
w=0
for ji2 in range(b):
    g=b-ji2-1
    if c[ji2][g]==0:
        w+=1
    if w==b:
        o=1
if o==1:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
x=[[0 for i in range(3)] for j in range(3)]
N=int(input())
if N>=3:
  for i in range(N):
    b=int(input())
    for j in range(3):
      if A[j]==b:
        x[0][j]=1
      elif B[j]==b:
        x[1][j]=1
      elif C[j]==b:
        x[2][j]=1
  flag=0
  if x[0][0]==1:
    if x[0][1]==1 and x[0][2]==1:
      flag=1
    if x[1][0]==1 and x[2][0]==1:
      flag=1
    if x[1][1]==1 and x[2][2]==1:
      flag=1
  if x[1][1]==1:
    if x[0][1]==1 and x[2][1]==1:
      flag=1
    if x[1][0]==1 and x[2][0]==1:
      flag=1
    if x[0][2]==1 and x[2][0]==1:
      flag=1
  if x[2][2]==1:
    if x[2][0]==1 and x[2][1]==1:
      flag=1
    if x[0][2]==1 and x[1][2]==1:
      flag=1
  if flag==1:
    print("Yes")
  else:
    print("No")
  #print(x)
else:
  print("No")

Submission status: Wrong Answer

Solution code:
A1_1,A1_2,A1_3 = map(int, input().split())
A2_1,A2_2,A2_3 = map(int, input().split())
A3_1,A3_2,A3_3 = map(int, input().split())
N =int(input())
B = []
for _ in range(N):
    B+=[input()]

a=str('yes')
b=str('no')
if A1_1 in B and A1_2 in B and A1_3 in B:
     print(a)
elif A2_1 in B and A2_2 in B and A2_3 in B:
    print(a)
elif A3_1 in B and A3_2 in B and A3_3 in B:
     print(a)
elif A1_1 in B and A2_1 in B and A3_1 in B:
    print(a)
elif A1_2 in B and A2_2 in B and A3_2 in B:
    print(a)
elif A1_3 in B and A2_3 in B and A3_3 in B:
    print(a)
elif A1_1 in B and A2_2 in B and A3_3 in B:
     print(a)
elif A1_3 in B and A2_2 in B and A3_1 in B:
    print(a)
else:
    print(b)

Submission status: Wrong Answer

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

N = int(input())

B = []
for _ in range(N):
    B.append(int(input()))

punch = []
for b in B:
    for row in range(3):
        if b in A[row]:
            punch.append((row, A[row].index(b)))

for i in range(3):
    for j in range(3):
        if (i, j) in punch:
            if ((i+1)%3, (j+1)%3) in punch and ((i-1)%3, (j-1)%3) in punch:
                print('Yes')
                exit()
            if ((i)%3, (j+1)%3) in punch and ((i)%3, (j-1)%3) in punch:
                print('Yes')
                exit()
            if ((i+1)%3, (j)%3) in punch and ((i-1)%3, (j)%3) in punch:
                print('Yes')
                exit()
            if ((i+1)%3, (j)%3) in punch and ((i)%3, (j+1)%3) in punch:
                print('Yes')
                exit()
print('No')

Submission status: Wrong Answer

Solution code:
bingo = []
for i in range(3):
  row = [int(j) for j in input().split()]
  bingo.append(row)
ans = "No"
n = int(input())
for i in range(n):
  lot = int(input())
  for j in range(len(bingo)):
    col = 0
    for k in range(len(bingo[j])):
      if bingo[j][k] == lot:
      	bingo[j][k] = -1
      	col += bingo[j][k]
    if sum(bingo[j]) == -3:
  	  ans = "Yes"
  if col == -3:
    ans = "Yes"
if (bingo[0][0] + bingo[1][1] + bingo[2][2]) == -3:
  ans = "No"
if (bingo[0][2] + bingo[1][1] + bingo[2][0]) == -3:
  ans = "No"
print(ans)

Submission status: Wrong Answer

Solution code:
n1 = list(map(int, input().split()))
n2 = list(map(int, input().split()))
n3 = list(map(int, input().split()))
arr = []
z=0
x = int(input())
for i in range(x):
    arr.append(int(input()))
    if arr[i] == n1[0] or arr[i] == n1[1] or arr[i] == n1[2] or arr[i] == n2[0] or arr[i] == n2[1] or arr[i] == n2[2] or arr[i] == n3[0] or arr[i] == n3[1] or arr[i] == n3[2]:
        z+=1
if z >= 3: print("Yes")
else: print("No")

Submission status: Wrong Answer

Solution code:
bingo = [ list(map(int,input().split(" "))) for i in range(3)]
N = int(input())
b = [int(input()) for i in range(N)]

list = [[0]*3]*3
flag = 0

#print(list)

for i in range(0, 3):
    for j in range(0, 3):
        for k in range(0, N):
            if bingo[i][j] == b[k]:
                list[i][j] = 1
                print(b[k])
#print(list)
#list = [[1,0,0], [1, 1, 0], [0,0,1]]

for i in range(0, 3):
    hantei = 0
    for j in range(0, 3):
        hantei = hantei + list[i][j]
    if hantei == 3:
        flag = 1
        break

for i in range(0, 3):
    hantei = 0
    for j in range(0, 3):
        hantei = hantei + list[j][i]
    if hantei == 3:
        flag = 1
        break

hantei = 0
for i in range(0, 3):
    hantei = hantei + list[i][i]
if hantei == 3:
    flag = 1

hantei = 0
for i in range(0, 3):
    hantei = hantei + list[i][2-i]
if hantei == 3:
    flag = 1


if flag == 1:
    print('Yes')
elif flag == 0:
    print('No')

Submission status: Wrong Answer

Solution code:
import numpy as np


A1 = list(map(int, input().split()))
A2 = list(map(int, input().split()))
A3 = list(map(int, input().split()))
N = int(input())
b = np.array([])
for _ in range(N):
    b = np.append(b, int(input()))
    
A = np.array([A1, A2, A3])
index = np.zeros((3,3))
for i in b:
  index += np.array(A==i, dtype=np.int)
sum2 = 0


for i in range(3):
  sum1 = np.sum(index[i])
  if sum1 == 3:
    ans1 = 1
  else:
    ans1 = 0
for i in range(3):
  for j in range(3):
    sum2 += index[i][j]
    if sum2 == 3:
      ans2 = 1
    else:
      ans2 = 0
if np.trace(index) == 3:
  ans3 = 1
else:
  ans3 = 0
index = index[:, ::-1]
if np.trace(index) == 3:
  ans4 = 1
else:
  ans4 = 0

y = ans1 + ans2 + ans3 + ans4
if y == 0:
  print("No")
else:
  print("Yes")

Submission status: Wrong Answer

Solution code:
def resolve():
    a = list(map(int, input().split()))
    a.extend(list(map(int, input().split())))
    a.extend(list(map(int, input().split())))
    n = int(input())
    for i in range(n):
        b = int(input())
        for j in range(len(a)):
            if a[j] == b:
                a[j] = -1
    x1 = a[0:3].count(-1)
    x2 = a[3:6].count(-1)
    x3 = a[6:9].count(-1)
    y1 = a[0:7:3].count(-1)
    y2 = a[1:8:3].count(-1)
    y3 = a[2:9:3].count(-1)
    nn = a[0:9:4].count(-1)
    nn2 = a[2:7:2]

    if x1 == 3 or x2 == 3 or x3 == 3 or y1 == 3 or y2 == 3 or y3 == 3 or nn == 3 or nn2 == 3:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    resolve()

Submission status: Wrong Answer

Solution code:
import sys
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 =[]
for i in range(n):
    b.append(int(input()))
#print(b)
for i in range(3):
    for j in range(3):
        if a[i][j] in b:
            a[i][j] = 0

Submission status: Wrong Answer

Solution code:
AA = list(map(int, input().split()))
AB = list(map(int, input().split()))
AC = list(map(int, input().split()))
N = int(input())
 
for i in range(N):
  B = int(input())
  for j in range(3):
    if AA[j] == B:
      AA[j] = 0
    elif AB[j] == B:
      AB[j] = 0
    elif AC[j] == B:
      AC[j] = 0
A = "No"
 
if AA[0] == 0:
  if (AA[1] == 0 and AA[2] == 0) or (AB[1] == 0 and AC[2] == 0):
    A = "Yes"
if AA[1] == 0:
  if AB[1] == 0 and AC[1] == 0:
    A = "Yes"
if AA[2] == 0:
  if (AB[2] == 0 and AC[2] == 0) or (AB[1] == 0 and AC[0] == 0):
    A = "Yes"
if AB[0] == 0:
  if AB[1] == 0 and AB[2] == 0:
    A = "Yes"
if AC[0] == 0:
  if AC[1] == 0 and AC[2] == 0:
    A = "Yes"
    
print(A)

Submission status: Wrong Answer

Solution code:
bingo = [0,1,3,5,7,8]
if 4 in bingo:
    if 0 in bingo:
        if 8 in bingo:
            print('Yes')
            exit()
    if 1 in bingo:
        if 7 in bingo:
            print('Yes')
            exit()
    if 2 in bingo:
        if 6 in bingo:
            print('Yes')
            exit()
    if 3 in bingo:
        if 5 in bingo:
            print('Yes')
            exit()
if 0 in bingo:
    if 1 in bingo:
        if 2 in bingo:
            print('Yes')
            exit()
    if 3 in bingo:
        if 6 in bingo: 
            print('Yes')
            exit()
if 8 in bingo:
    if 2 in bingo:
        if 5 in bingo:
            print('Yes')
            exit()
    if 6 in bingo:
        if 7 in bingo:           
            print('Yes')
            exit()
print('No')

Submission status: Wrong Answer

Solution code:
a, b, c = input().split()
d, e, f = input().split()
g, h, i = input().split()
N = int(input())

num_list = []
for _ in range(N):
    num_list.append(int(input()))

for j in num_list:
    if a == j:
        a = 101
    if b == j:
        b = 101
    if c == j:
        c = 101
    if d == j:
        d = 101
    if e == j:
        e = 101
    if f == j:
        f = 101
    if g == j:
        g = 101
    if h == j:
        h = 101
    if i == j:
        i = 101

answer = 'No'
if a + b + c == 303:
    answer = 'Yes'
if d + e + f == 303:
    answer = 'Yes'
if g + h + i == 303:
    answer = 'Yes'
if a + d + g == 303:
    answer = 'Yes'
if b + e + h == 303:
    answer = 'Yes'
if c + f + i == 303:
    answer = 'Yes'
if a + e + i == 303:
    answer = 'Yes'
if c + e + g == 303:
    answer = 'Yes'

print(answer)