본문 바로가기
알고리즘/Codeforces

Codeforces Round #658 (Div. 2) AB

by 유시은 2020. 8. 6.
from sys import stdin
T=int(stdin.readline())
A=[]
B=[]
for _ in range(T):
    n,m=map(int,stdin.readline().split())
    A=list(map(int,stdin.readline().split()))
    B=list(map(int,stdin.readline().split()))
    res=list(set(A) & set(B))
    if len(res)==0:
        print("NO")
    else:
        print("YES")
        print(1,res[0])

 

A - Common Subsequence

 

from sys import stdin
 
T=int(stdin.readline())
for _ in range(T):
    cnt=0
    N=int(stdin.readline())
    li=list(map(int,stdin.readline().split()))
    for i in li:
        if i==1:
            cnt+=1
        else:
            break
 
    if cnt%2==0:
        if cnt==N:
            print("Second")
        else:
            print("First")
    else:
        if cnt==N:
            print("First")
        else:
            print("Second")

 

B - Sequential Nim

태그

,

댓글0