Problem:


Score : 200 points

Problem Statement

There are four towns, numbered 1,2,3 and 4.
Also, there are three roads. The i-th road connects different towns a_i and b_i bidirectionally.
No two roads connect the same pair of towns. Other than these roads, there is no way to travel between these towns, but any town can be reached from any other town using these roads.

Determine if we can visit all the towns by traversing each of the roads exactly once.

Constraints

1 \leq a_i,b_i \leq 4(1\leq i\leq 3)

a_i and b_i are different. (1\leq i\leq 3)

No two roads connect the same pair of towns.

Any town can be reached from any other town using the roads.

Input

Input is given from Standard Input in the following format:

a_1 b_1
a_2 b_2
a_3 b_3

Output

If we can visit all the towns by traversing each of the roads exactly once, print YES; otherwise, print NO.

Sample Input 1

4 2
1 3
2 3

Sample Output 1

YES

We can visit all the towns in the order 1,3,2,4.

Sample Input 2

3 2
2 4
1 2

Sample Output 2

NO

Sample Input 3

2 1
3 2
4 3

Sample Output 3

YES



Sample input:
4 2
1 3
2 3


Sample output:
YES

Submission status: Accepted

Solution code:
a = [0] * 4
for i in range(3) :
  x, y = map(int, input().split())
  a[x-1] = a[x-1] + 1
  a[y-1] = a[y-1] + 1
if a[0] ^ a[1] ^ a[2] ^ a[3] == 0 : print("YES")
else : print("NO")

Submission status: Accepted

Solution code:
l=[]
for i in range(3):
    l.extend(list(map(int,input().split())))
m=[0,0,0,0]
for i in range(1,5):
    m[i-1]=l.count(i)
if sorted(m) == [1,1,2,2]:
    print("YES")
else:
    print("NO")

Submission status: Accepted

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

aaa.sort()
cnt = 0
prev = aaa[0]
c = []
for i, aa in enumerate(aaa):
    if aa == prev:
        cnt += 1
    else:
        c.append(cnt)
        prev = aa
        cnt = 1
c.append(cnt)
c.sort()
if [1, 1, 2, 2] == c:
    print("YES")
else:
    print("NO")

Submission status: Accepted

Solution code:
dim = [0,0,0,0]

for _ in range(3):
	a, b = [int(x) for x in input().split()]
	dim[a-1] += 1
	dim[b-1] += 1

if 3 in dim:
	print("NO")
else:
	print("YES")

Submission status: Accepted

Solution code:
a1,b1=input().split()
a2,b2=input().split()
a3,b3=input().split()
t=a1+b1+a2+b2+a3+b3
if t.count("1")*t.count("2")*t.count("3")*t.count("4")==0 or max(t.count("1"),t.count("2"),t.count("3"),t.count("4"))==3:
    print("NO")
else:
    print("YES")

Submission status: Accepted

Solution code:
abs = [[int(x) for x in input().split()] for _ in range(3)]

ns = {1: 0, 2: 0, 3: 0, 4: 0}
for a, b in abs:
    ns[a] += 1
    ns[b] += 1
ans = max(ns.values()) == 2

print("YES" if ans else "NO")

Submission status: Accepted

Solution code:
arr=[]
for i in range(3):
  a,b=map(int,input().split())
  arr.append(a)
  arr.append(b)
if arr.count(1)==3 or arr.count(2)==3 or arr.count(3)==3 or arr.count(4)==3:
  print('NO')
else:
  print('YES')

Submission status: Accepted

Solution code:
if __name__=="__main__":
    ind = [0, 0, 0, 0]
    for i in range(3):
        x, y = input().split(' ')
        x = int(x);
        y = int(y);
        ind[x - 1] += 1
        ind[y - 1] += 1
    sum = 0;
    for i in ind:
        sum += (i & 1)
    if sum == 0 or sum == 2:
        print('YES')
    else:
        print('NO')

Submission status: Accepted

Solution code:
a,b = input().split()
c,d = input().split()
e,f = input().split()
A = [a,b,c,d,e,f]
if max(A.count('1'),A.count('2'),A.count('3'),A.count('4')) >= 3:
	print("NO")
else:
	print("YES")

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys

YES = "YES"  # type: str
NO = "NO"  # type: str

def solve(a: "List[int]", b: "List[int]"):
    count = [0] * 4
    for i in range(3):
        count[a[i] - 1] += 1
        count[b[i] - 1] += 1
    if max(count) >= 3:
        ret = NO
    else:
        ret = YES
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    a = [int()] * (3)  # type: "List[int]" 
    b = [int()] * (3)  # type: "List[int]" 
    for i in range(3):
        a[i] = int(next(tokens))
        b[i] = int(next(tokens))
    solve(a, b)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
#input=sys.stdin.read
adj=[[] for i in range(4)]
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))

for i in range(3):
    a,b=MAP()
    adj[a-1].append(b-1)
    adj[b-1].append(a-1)
for i in range(4):
    if len(adj[i])>2:
        print("NO")
        exit()
print("YES")

Submission status: Accepted

Solution code:
a, b = map(int, raw_input().split())
c, d = map(int, raw_input().split())
e, f = map(int, raw_input().split())
r = a^b^c^d^e^f
bad = 1^2^3^4
if r == bad:
  print "NO"
else:
  print "YES"

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N,M=4,3
nodes=[[] for i in range(N)]
for i in range(M):
    a,b=MAP()
    nodes[a-1].append(b-1)
    nodes[b-1].append(a-1)

if all(len(nodes[i])<=2 for i in range(N)):
    YES()
else:
    NO()

Submission status: Accepted

Solution code:
array = []
for i in range(3):
    array.append([int(i) for i in input().split()])
array_and = set(array[0]) & set(array[1]) & set(array[2])
if len(array_and) == 0:
    print('YES')
else:
    print('NO')

Submission status: Accepted

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

for i in range(1, 5):
    cnt = 0
    for ab in AB:
        if i in ab:
            cnt += 1
        if cnt == 3:
            print("NO")
            exit()
else:
    print("YES")

Submission status: Accepted

Solution code:

a = [0] * 3
b = [0] * 3

for i in range(3):
    a[i],b[i] = map(int,input().split())
    
count = [0] * 4
for i in range(3):
    for j in range(1,5):
        if(a[i] == j):
            count[j-1] += 1
        if(b[i] == j):
            count[j-1] += 1
        
if max(count) > 2:
    print('NO')
else:
    print('YES')

Submission status: Accepted

Solution code:
A=[]
A+=[int(i) for i in input().split()]
A+=[int(i) for i in input().split()]
A+=[int(i) for i in input().split()]

B = [A.count(i) for i in range(1,5)]
if B.count(2) == 2 and B.count(1) == 2:
  print("YES")
else:
  print("NO")

Submission status: Accepted

Solution code:
import collections

a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
c = [int(i) for i in input().split()]

x = a+b+c
c = collections.Counter(x)

if len(list(filter(lambda x:x>2,c.values()))) > 0:
    print("NO")
else:
    print("YES")

Submission status: Accepted

Solution code:
import collections

li = []
for i in range(3):
    li += list( map( int, input().split() ) )

c = collections.Counter( li )
if c.most_common()[0][1] >= 3: print( 'NO' )
else: print( 'YES' )

Submission status: Accepted

Solution code:
#/usr/bin/env python3

from collections import Counter
a = Counter()
for _ in range(3):
    m,n = map(int, input().split())
    a[m]  += 1
    a[n] += 1
    if a[m] > 2 or a[n] > 2:
        print("NO")
        exit(0)
print("YES")

Submission status: Accepted

Solution code:
a = [[int(_) for _ in input().split()] for _ in range(3)]
a = sum(a, [])
num = []
for i in range(1, 5):
    num.append(a.count(i))

print("YES" if num.count(2)==2 and num.count(1)==2 else "NO")

Submission status: Accepted

Solution code:
lis =[]
for _ in range(3):
  a, b = map(int, input().split())
  lis.append(a)
  lis.append(b)
boo = False
for i in range(1, 5):
  if lis.count(i) >= 3:
    boo = True
if boo:
  print("NO")
else:
  print("YES")

Submission status: Accepted

Solution code:
flag = 0
a = []
for x in range(3):
    a +=list(map(int,input().split()))
if a.count(1) == 2:
    flag += 1
if a.count(2) == 2: 
    flag += 1
if a.count(3) == 2:
    flag += 1
if a.count(4) == 2:
    flag += 1
if flag == 2:
    print('YES')
else:
    print('NO')

Submission status: Accepted

Solution code:
x=[0,0,0,0]
for i in range(3):
  a,b=map(int,input().split())
  x[a-1]+=1
  x[b-1]+=1
if x.count(3)==0:print("YES")
else:print("NO")

Submission status: Accepted

Solution code:
l = [0, 0, 0, 0, 0]
for _ in range(3):
  a, b = map(int,input().split())
  l[a] += 1
  l[b] += 1
if sorted(l) == [0, 1, 1, 2, 2]:
  print("YES")
else:
  print("NO")

Submission status: Accepted

Solution code:
#!usr/bin/env python3
from collections import defaultdict
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007

#A

"""
s = S()
n = len(s)
if s == list("keyence"):
    print("YES")
    quit()
for i in range(n):
    for j in range(i+1,n):
        print(s[:i]+s[j:])
        if s[:i]+s[j:] == list("keyence"):
            print("YES")
            quit()
print("NO")
"""
#B
c = LIR(3)
v = [[] for i in range(4)]
for i in range(3):
    c[i][0] -= 1
    c[i][1] -= 1
    v[c[i][0]].append(c[i][1])
    v[c[i][1]].append(c[i][0])

for i in range(4):
    li = [True for i in range(4)]
    li[i] = False
    q = [i]
    c = 0
    while q:
        x = q.pop(-1)
        k = 0
        for j in v[x]:
            if li[j]:
                li[j] = False
                q.append(j)
                if k == 0:
                    c += 1
                    k += 1
    if c == 3:
        print("YES")
        quit()
print("NO")
#C

#D

#E

#F

#G

#H

#I

#J

#K

#L

#M

#N

#O

#P

#Q

#R

#S

#T

Submission status: Accepted

Solution code:
c = [0]*5
for i in range(3):
    a, b = map(int, input().split())
    c[a] += 1
    c[b] += 1
if max(c) == 3:
    print('NO')
else:
    print('YES')

Submission status: Accepted

Solution code:
p = [0,0,0,0]
for i in range(3):
    ai, bi = map(int, input().split())
    p[ai-1] += 1
    p[bi-1] += 1

if 3 in p:
    print('NO')
else:
    print('YES')

Submission status: Accepted

Solution code:
oira = str()
S = str()
for i in range(3):
	s = input().split()
	S += s[0] + s[1]
if (S.count('1') == 3)|(S.count('2')==3)|(S.count('3')==3)|(S.count('4')==3):
	print('NO')
else:
	print('YES')

Submission status: Accepted

Solution code:
ans = [0,0,0,0]
for i in range(3):
  for j in input().split():
    ans[int(j)-1]+=1
if ans.count(1)==ans.count(2)==2:
  print('YES')
else:
  print('NO')

Submission status: Accepted

Solution code:
list_ = [[int(x) for x in input().split()] for i in range(3)]
count = [0]*4
for i in range(3):
  count[list_[i][0]-1]+=1
  count[list_[i][1]-1]+=1
if 3 in count:
  print('NO')
else:
  print('YES')

Submission status: Accepted

Solution code:
L = [set(map(int,input().split())) for i in range(3)]
L += [set([1,0]),set([2,0]),set([3,0]),set([4,0])]
import copy
def dfs(left_towns, current_town):
    if len(left_towns) == 0:
        return 1
    
    ret = 0
    for t in left_towns:
        if set([t,current_town]) in L:
            new_left_towns = copy.deepcopy(left_towns)
            new_left_towns.remove(t)
            ret += dfs(new_left_towns, t)
    
    if ret>0:
        return 1
    else:
        return 0

ans = 'YES' if dfs([1,2,3,4],0)>0 else 'NO'
print(ans)

Submission status: Accepted

Solution code:
AB = [[int(i) for i in input().split()] for j in range(3)]

List = [0 for i in range(4)]
for i in range(len(AB)):
    for j in range(2):
        List[AB[i][j]-1] += 1
one = 0
two = 0
for i in List:
    if i == 1:
        one += 1
    if i == 2:
        two += 1
ans = "NO"
if one == 2 and two == 2:
    ans = "YES"

print(ans)

Submission status: Accepted

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

flattened = [i for sub in edges for i in sub]
cont = sorted([flattened.count(i) for i in range(1, 5)])
ans = 'YES' if cont == [1,1,2,2] else 'NO'
print(ans)

Submission status: Accepted

Solution code:
E = []
for i in range(3):
  E.append(list(map(int, input().split())))
  
A = [0]*4

for i in range(3):
  A[E[i][0] - 1] += 1
  A[E[i][1] - 1] += 1
  
if A[0] * A[1] * A[2] * A[3] == 4:
  print('YES')
else:
  print('NO')

Submission status: Accepted

Solution code:
ab=[list(map(int,input().split())) for _ in range(3)]
a,b,c,d=0,0,0,0
for k in ab:
    for t in k:
        if t==1:
            a+=1
        elif t==2:
            b+=1
        elif t==3:
            c+=1
        else:
            d+=1
z=[a,b,c,d]
if z.count(2)==2 and z.count(1)==2:
    print("YES")
else:
    print("NO")

Submission status: Accepted

Solution code:
L = [0, 0, 0, 0]
for i in range(3):
	a, b = list(map(int, input().split()))
	L[a - 1] += 1
	L[b - 1] += 1

L = sorted(L)
if L[0] == 1 and L[-1] == 2:
	print("YES")
else:
	print("NO")

Submission status: Accepted

Solution code:
l1 = set(tuple(map(int,input().split())))
l2 = set(tuple(map(int,input().split())))
l3 = set(tuple(map(int,input().split())))

L = (l1,l2,l3)

town = [1,2,3,4]

ret = 0

for t1 in town:
    for t2 in town:
        if t1==t2: continue
        if not {t1,t2} in L: continue
        for t3 in town:
            if t3==t2 or t3==t1: continue
            if not {t2,t3} in L: continue
            for t4 in town:
                if t4==t3 or t4==t2 or t4==t1: continue
                if not {t3,t4} in L: continue
                ret += 1

ans = 'YES' if ret>0 else 'NO'
print(ans)

Submission status: Accepted

Solution code:
L = []
l1 = set(tuple(map(int,input().split())))
l2 = set(tuple(map(int,input().split())))
l3 = set(tuple(map(int,input().split())))
L.append(l1)
L.append(l2)
L.append(l3)
L += [{0,1},{0,2},{0,3},{0,4}]

def dfs(left_town, current_town):
    if left_town == []:
        return 1

    ret = 0
    for t in left_town:
        if {current_town, t} in L:
            ret += dfs([left_town[index] for index,val in enumerate(left_town) if not val==t],t)
    
    if ret == 0:
        return 0
    else:
        return 1

ans = "YES" if dfs([1,2,3,4],0)==1 else "NO"
print(ans)

Submission status: Accepted

Solution code:
import sys



towncount = [0, 0, 0, 0]
for i in range(3):
	line = sys.stdin.readline()
	values = line.split(" ")
	for value in values:
		towncount[int(value)-1] += 1

for count in towncount:
	if count > 2:
		print("NO")
		exit()

print("YES")

Submission status: Accepted

Solution code:
load = list()
for i in range(3):
  a, b = list(map(int, input().split()))
  load.append(a)
  load.append(b)
error = 0
for i in range(1, 5):
  if load.count(i) >= 3:
    error += 1
if error >= 1:
  print("NO")
else:
  print("YES")

Submission status: Accepted

Solution code:
t = [0] * 4
for i in range(3):
    a, b = map(int, input().split())
    t[a - 1] += 1
    t[b - 1] += 1
print('NO') if max(t)==3 else print('YES')

Submission status: Accepted

Solution code:
count1=0
count2=0
count3=0
count4=0
for i in range(3):
  a,b=(int(x) for x in input().split())
  if a==1:
    count1 = count1 + 1
  elif a==2:
    count2 = count2 + 1
  elif a==3:
    count3 = count3 + 1
  elif a==4:
    count4 = count4 + 1
  if b==1:
    count1 = count1 + 1
  elif b==2:
    count2 = count2 + 1
  elif b==3:
    count3 = count3 + 1
  elif b==4:
    count4 = count4 + 1
if count1>2 or count2>2 or count3>2 or count4>2:
  print("NO")
else:
  print("YES")

Submission status: Accepted

Solution code:
a1,b1=map(int,input().split())
a2,b2=map(int,input().split())
a3,b3=map(int,input().split())
l=[a1,a2,a3,b1,b2,b3]
L=[]
for i in range(1,5):
  L.append(l.count(i))
L.sort()
if L==[1,1,2,2]:print('YES')
else:print('NO')

Submission status: Accepted

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

import collections
c = collections.Counter(arr)
if (len(set(arr))!=4) or (3 in c.values()):
  print("NO")
else:
  print("YES")

Submission status: Accepted

Solution code:
def solution(edges):
    num_of_neighbor = {}
    for e in edges:
        if e[0] in num_of_neighbor:
            num_of_neighbor[e[0]] += 1
        else:
            num_of_neighbor[e[0]] = 1
        if e[1] in num_of_neighbor:
            num_of_neighbor[e[1]] += 1
        else:
            num_of_neighbor[e[1]] = 1
    n_2 = 0
    n_1 = 0
    for n in num_of_neighbor:
        if num_of_neighbor[n] == 2:
            n_2 += 1
        elif num_of_neighbor[n] == 1:
            n_1 += 1

    if n_2 == 2 and n_1 == 2:
        return 'YES'
    else:
        return 'NO'

e1 = [int(s) for s in input().split(' ')]
e2 = [int(s) for s in input().split(' ')]
e3 = [int(s) for s in input().split(' ')]
edges = [e1, e2, e3]
print(solution(edges))

Submission status: Accepted

Solution code:
def solution(path1, path2, path3):
    counts = [0, 0, 0, 0]
    paths = [path1, path2, path3]
    for path in paths:
        counts[path[0] - 1] += 1
        counts[path[1] - 1] += 1

    countsOfCounts = [0, 0]
    for count in counts:
        if count == 1:
            if countsOfCounts[0] == 2:
                return "NO"
            countsOfCounts[0] += 1
        elif count == 2:
            if countsOfCounts[1] == 2:
                return "NO"
            countsOfCounts[1] += 1
        else:
            return "NO"
    return "YES"


path1 = [int(s) for s in input().split(' ')]
path2 = [int(s) for s in input().split(' ')]
path3 = [int(s) for s in input().split(' ')]

print(solution(path1, path2, path3))

Submission status: Accepted

Solution code:
D = [0]*4
for i in range(3):
    a, b = map(int, input().split())
    D[a-1] += 1
    D[b-1] += 1
C = [0]*4
for d in D:
    C[d] += 1
print("YES" if C == [0, 2, 2, 0] else "NO")

Submission status: Accepted

Solution code:
noc = [0] * 4

for i in range(3):
    l = list(map(int, input().split()))
    for j in range(2):
        noc[l[j] - 1] += 1

if 3 in noc:
    print('NO')
else:
    print('YES')

Submission status: Accepted

Solution code:
g=[0,0,0,0]
one=0
two=0

for i in range(3):
  a,b=map(int,input().split())
  g[a-1]+=1
  g[b-1]+=1
  
for i in range(len(g)):
  if g[i]==1:
    one+=1
  if g[i]==2:
    two+=1
if one==2 and two==2:
  print('YES')
else:
  print('NO')

Submission status: Accepted

Solution code:
n = [list(map(int, input().split())) for _ in range(3)]
c = [0] * 4
for i in n:
    for j in i:
        c[j - 1] += 1
a = len(list(filter(lambda x : x % 2 == 1, c)))
if a == 2:
    print("YES")
else:
    print("NO")

Submission status: Accepted

Solution code:
r = [input().split(" ") for i in range(3)]
r_f = [f for i in r for f in i]
judge = "NO" if max([r_f.count(str(i)) for i in range(1,5)])==3 else "YES"
print(judge)

Submission status: Accepted

Solution code:
cnt = [0] * 4
for i in range(3):
    a, b = list(map(int, input().split()))
    cnt[a-1] += 1
    cnt[b-1] += 1
cnt = sorted(cnt)
print("YES" if cnt == [1, 1, 2, 2] else "NO")

Submission status: Accepted

Solution code:
path=[]
for i in range(3):
    n, k = map(int, input().split())
    path.append(n)
    path.append(k)

if 0 < path.count(1) < 3 and 0 < path.count(2) < 3 and 0 < path.count(3) < 3 and 0 < path.count(4) < 3:
    print('YES')
else:
    print('NO')

Submission status: Accepted

Solution code:
path = {}
for i in range(1,5):
    city = int(i)
    path[i] = 0


for i in range(3):
    city_1 ,city_2 = map(int,input().split())
    path[city_1] += 1
    path[city_2] += 1

d = 1
for value in path.values():
    d *= value

if d == 4:
    print("YES")
else:
    print("NO")

Submission status: Accepted

Solution code:
import numpy as np
ans = 'YES'
a = np.array([])
for i in range(3):
    b, c = input().split()
    a = np.append(a, [b, c])
a = a.astype(np.int32)
for i in range(4):
    count = np.sum(a == i + 1)
    if count > 2:
        ans = 'NO'
        break
print(ans)

Submission status: Accepted

Solution code:
import itertools
data = []
for i in range(3):
    a,b = map(int,input().split())
    data.append([a,b])
    data.append([b,a])

seq = [1,2,3,4]
test = list(itertools.permutations(seq))
check = False
for i in range(len(test)):
    temp = True
    for k in range(3):
        if [test[i][k],test[i][k+1]] not in data:
            temp = False
            break
    if temp:
        check = True
        break
if check:
    print("YES")
else:
    print("NO")

Submission status: Accepted

Solution code:
def f():
    a = list(map(int, input().split()))+list(map(int, input().split()))+list(map(int, input().split()))
    for i in range(4):
        if sum(x==i+1 for x in a) > 2:
            print('NO')
            return
    print('YES')
f()

Submission status: Accepted

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

r = 1
for i in range(1,5):
  r *= pathes.count(i)

result = 'YES' if r%3>0 else 'NO'

print(result)

Submission status: Accepted

Solution code:
def f():
    a = list(map(int, input().split()))+list(map(int, input().split()))+list(map(int, input().split()))
    b = []
    for i in range(4):
        b.append(sum(x==i+1 for x in a))
    for i in b:
        if i > 2:
            print('NO')
            return
    print('YES')
f()

Submission status: Accepted

Solution code:
# coding: utf-8
import sys
# import bisect
# import math
# import numpy as np


"""Template"""


class IP:
    """
    入力を取得するクラス
    """
    def __init__(self):
        self.input = sys.stdin.readline

    def I(self):
        """
        1文字の取得に使います
        :return: int
        """
        return int(self.input())

    def S(self):
        """
        1文字の取得(str
        :return: str
        """
        return self.input()

    def IL(self):
        """
        1行を空白で区切りリストにします(int
        :return: リスト
        """
        return list(map(int, self.input().split()))

    def SL(self):
        """
        1行の文字列を空白区切りでリストにします
        :return: リスト
        """
        return list(map(str, self.input().split()))

    def ILS(self, n):
        """
        1列丸々取得します(int
        :param n: 行数
        :return: リスト
        """
        return [int(self.input()) for _ in range(n)]

    def SLS(self, n):
        """
        1列丸々取得します（str
        :param n: 行数
        :return: リスト
        """
        return [self.input() for _ in range(n)]

    def SILS(self, n):
        """
        Some Int LineS
        横に複数、縦にも複数
        :param n: 行数
        :return: list
        """
        return [self.IL() for _ in range(n)]

    def SSLS(self, n):
        """
        Some String LineS
        :param n: 行数
        :return: list
        """
        return [self.SL() for _ in range(n)]


class Idea:
    def __init__(self):
        pass

    def HF(self, p):
        """
        Half enumeration
        半分全列挙です
        pの要素の和の組み合わせを作ります。
        ソート、重複削除行います
        :param p: list : 元となるリスト
        :return: list : 組み合わせられた和のリスト
        """
        return sorted(set(p[i] + p[j] for i in range(len(p)) for j in range(i, len(p))))

    def Bfs2(self, a):
        """
        bit_full_search2
        bit全探索の改良版
        全探索させたら2進数のリストと10進数のリストを返す
        :return: list２つ : １個目 2進数(16桁)  2個目 10進数
        """
        # 参考
        # https://blog.rossywhite.com/2018/08/06/bit-search/
        # https://atcoder.jp/contests/abc105/submissions/4088632
        value = []
        for i in range(1 << len(a)):
            output = []

            for j in range(len(a)):
                if self.bit_o(i, j):
                    """右からj+1番目のiが1かどうか判定"""
                    # output.append(a[j])
                    output.append(a[j])
            value.append([format(i, 'b').zfill(16), sum(output)])

        value.sort(key=lambda x: x[1])
        bin = [value[k][0] for k in range(len(value))]
        val = [value[k][1] for k in range(len(value))]
        return bin, val

    def S(self, s, r=0, m=-1):
        """
        ソート関係行います。色々な設定あります。
        :param s: 元となるリスト
        :param r: reversするかどうか 0=False 1=True
        :param m: （2次元配列）何番目のインデックスのソートなのか
        :return: None
        """
        r = bool(r)
        if m == -1:
            s.sort(reverse=r)
        else:
            s.sort(reverse=r, key=lambda x: x[m])

    def bit_n(self, a, b):
        """
        bit探索で使います。0以上のときにTrue出します
        自然数だからn
        :param a: int
        :param b: int
        :return: bool
        """
        return bool((a >> b & 1) > 0)

    def bit_o(self, a, b):
        """
        bit探索で使います。1のときにTrue出すよ
        oneで1
        :param a: int
        :param b: int
        :return: bool
        """
        return bool(((a >> b) & 1) == 1)

    def ceil(self, x, y):
        """
        Round up
        小数点切り上げ割り算
        :param x: int
        :param y: int
        :return: int
        """
        return -(-x//y)

    def ave(self, a):
        """
        平均を求めます
        :param a: list
        :return: int
        """
        return sum(a) / len(a)

    def d(self, p):
        re = 0
        for i in range(len(p) - 1):
            re += ((p[i][0] - p[i + 1][0]) ** 2 + (p[i][1] - p[i + 1][1]) ** 2) ** 0.5
        return re


"""ここからメインコード"""


def main():
    # 1文字に省略
    r, e = range, enumerate
    ip = IP()
    id = Idea()

    """この下から書いてね"""
    s = [0] * 4
    for _ in [0] * 3:
        a = ip.IL()
        s[a[0] - 1] += 1
        s[a[1] - 1] += 1

    o = sum(x for x in s if x % 2 == 1)
    if o == 0 or o == 2:
        print("YES")
    else:
        print("NO")


main()

Submission status: Accepted

Solution code:
# coding: utf-8
import sys
# import bisect
# import math
import numpy as np


"""Template"""


class IP:
    """
    入力を取得するクラス
    """
    def __init__(self):
        self.input = sys.stdin.readline

    def I(self):
        """
        1文字の取得に使います
        :return: int
        """
        return int(self.input())

    def S(self):
        """
        1文字の取得(str
        :return: str
        """
        return self.input()

    def IL(self):
        """
        1行を空白で区切りリストにします(int
        :return: リスト
        """
        return list(map(int, self.input().split()))

    def SL(self):
        """
        1行の文字列を空白区切りでリストにします
        :return: リスト
        """
        return list(map(str, self.input().split()))

    def ILS(self, n):
        """
        1列丸々取得します(int
        :param n: 行数
        :return: リスト
        """
        return [int(self.input()) for _ in range(n)]

    def SLS(self, n):
        """
        1列丸々取得します（str
        :param n: 行数
        :return: リスト
        """
        return [self.input() for _ in range(n)]

    def SILS(self, n):
        """
        Some Int LineS
        横に複数、縦にも複数
        :param n: 行数
        :return: list
        """
        return [self.IL() for _ in range(n)]

    def SSLS(self, n):
        """
        Some String LineS
        :param n: 行数
        :return: list
        """
        return [self.SL() for _ in range(n)]


class Idea:
    def __init__(self):
        pass

    def HF(self, p):
        """
        Half enumeration
        半分全列挙です
        pの要素の和の組み合わせを作ります。
        ソート、重複削除行います
        :param p: list : 元となるリスト
        :return: list : 組み合わせられた和のリスト
        """
        return sorted(set(p[i] + p[j] for i in range(len(p)) for j in range(i, len(p))))

    def Bfs2(self, a):
        """
        bit_full_search2
        bit全探索の改良版
        全探索させたら2進数のリストと10進数のリストを返す
        :return: list２つ : １個目 2進数(16桁)  2個目 10進数
        """
        # 参考
        # https://blog.rossywhite.com/2018/08/06/bit-search/
        # https://atcoder.jp/contests/abc105/submissions/4088632
        value = []
        for i in range(1 << len(a)):
            output = []

            for j in range(len(a)):
                if self.bit_o(i, j):
                    """右からj+1番目のiが1かどうか判定"""
                    # output.append(a[j])
                    output.append(a[j])
            value.append([format(i, 'b').zfill(16), sum(output)])

        value.sort(key=lambda x: x[1])
        bin = [value[k][0] for k in range(len(value))]
        val = [value[k][1] for k in range(len(value))]
        return bin, val

    def S(self, s, r=0, m=-1):
        """
        ソート関係行います。色々な設定あります。
        :param s: 元となるリスト
        :param r: reversするかどうか 0=False 1=True
        :param m: （2次元配列）何番目のインデックスのソートなのか
        :return: None
        """
        r = bool(r)
        if m == -1:
            s.sort(reverse=r)
        else:
            s.sort(reverse=r, key=lambda x: x[m])

    def bit_n(self, a, b):
        """
        bit探索で使います。0以上のときにTrue出します
        自然数だからn
        :param a: int
        :param b: int
        :return: bool
        """
        return bool((a >> b & 1) > 0)

    def bit_o(self, a, b):
        """
        bit探索で使います。1のときにTrue出すよ
        oneで1
        :param a: int
        :param b: int
        :return: bool
        """
        return bool(((a >> b) & 1) == 1)

    def ceil(self, x, y):
        """
        Round up
        小数点切り上げ割り算
        :param x: int
        :param y: int
        :return: int
        """
        return -(-x//y)

    def ave(self, a):
        """
        平均を求めます
        :param a: list
        :return: int
        """
        return sum(a) / len(a)

    def d(self, p):
        re = 0
        for i in range(len(p) - 1):
            re += ((p[i][0] - p[i + 1][0]) ** 2 + (p[i][1] - p[i + 1][1]) ** 2) ** 0.5
        return re


"""ここからメインコード"""


def main():
    # 1文字に省略
    r, e = range, enumerate
    ip = IP()
    id = Idea()

    """この下から書いてね"""
    s = [0] * 4
    for _ in [0] * 3:
        a = ip.IL()
        s[a[0] - 1] += 1
        s[a[1] - 1] += 1

    o = sum(x for x in s if x % 2 == 1)
    if o == 0 or o == 2:
        print("YES")
    else:
        print("NO")


main()

Submission status: Accepted

Solution code:
tree = [ [] for _ in range(4) ]

for i in range(3):
    a, b = map(int, input().split())
    a -= 1; b -= 1;
    tree[a].append(b)
    tree[b].append(a)

for i in range(4):
    visited = [ False for _ in range(4) ]
    cur = i
    visited[cur] = True
    for j in range(3):
        for v in tree[cur]:
            if not visited[v]:
                next_v = v
                break
        visited[next_v] = True
        cur = next_v

    if all(visited):
        print ("YES")
        exit()

print("NO")

Submission status: Accepted

Solution code:
tree = [ [] for _ in range(4) ]

for i in range(3):
    a, b = map(int, input().split())
    a -= 1; b -= 1;
    tree[a].append(b)
    tree[b].append(a)

for i in range(4):
    visited = [ False for _ in range(4) ]
    cur = i
    visited[cur] = True
    for j in range(3):
        for v in tree[cur]:
            if not visited[v]:
                next_v = v
                break
        visited[next_v] = True
        cur = next_v

print ( "YES" if all(visited) else "NO" )

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import sys
sum = [0]*4

for i in range(0,3):
    a, b = map(int, input().split())
    sum[a-1] +=1
    sum[b-1] +=1

for i in range(0,4):
    if sum[i] >= 3:
        print("NO")
        sys.exit()

print("YES")

Submission status: Accepted

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


if 0 in bridge or 3 in bridge:
    print('NO')
else:
    print('YES')