Problem:


  MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});

Dice III

  Write a program which reads the two dices constructed in the same way as Dice I, and determines whether these two dices are identical. You can roll a dice in the same way as Dice I, and if all integers observed from the six directions are the same as that of another dice, these dices can be considered as identical.

Input

  In the first line, six integers assigned to faces of a dice are given in ascending order of their corresponding labels.

    In the second line, six integers assigned to faces of another dice are given in ascending order of their corresponding labels.

Output

  Print "Yes" if two dices are identical, otherwise "No" in a line.

Constraints

$0 \leq $ the integer assigned to a face $ \leq 100$

Sample Input 1

1 2 3 4 5 6
6 2 4 3 5 1

Sample Output 1

Yes

Sample Input 2

1 2 3 4 5 6
6 5 4 3 2 1

Sample Output 2

No



Sample input:
1 2 3 4 5 6
6 2 4 3 5 1


Sample output:
Yes

Submission status: Accepted

Solution code:
diceA = list(map(int, input().split()))

diceB1 = list(map(int, input().split()))

diceB2 = [diceB1[0],diceB1[1],diceB1[2],diceB1[4],diceB1[3],diceB1[5]]

diceC = [[1,2,3,5,4,2,3,5,6],[2,1,4,6,3,1,4,6,5],[3,1,2,6,5,1,2,6,4],[4,1,5,6,2,1,5,6,3],[5,1,3,6,4,1,3,6,2],[6,2,4,5,3,2,4,5,1]]

for i in range(6):
  if diceB2[0] == diceA[i]:
    for j in range(1,5):
      if diceB2[1] == diceA[diceC[i][j]-1]:
        for k in range(1,4):
          if diceB2[1+k] == diceA[diceC[i][j+k]-1]:
            m = "Yes"
          else:
            m = "No"
            break
        if m == "Yes":
          if diceB2[5] == diceA[diceC[i][8]-1]:
            m = "Yes"

print(m)

Submission status: Accepted

Solution code:

class Dice():

    def __init__(self, d):
        self.d = d
        self.north = [2, 6, 3, 4, 1, 5]
        self.south = [5, 1, 3, 4, 6, 2]
        self.east = [4, 2, 1, 6, 5, 3]
        self.west = [3, 2, 6, 1, 5, 4]
        self.label = [(self.d[0], self.d[1], self.d[2])]

    def roll(self, direction):
        if direction == 'S':
            self.d = [ self.d[self.south[i]-1] for i in range(6) ]
        elif direction == 'N':
            self.d = [ self.d[self.north[i]-1] for i in range(6) ]
        elif direction == 'E':
            self.d = [ self.d[self.east[i]-1] for i in range(6) ]
        elif direction == 'W':
            self.d = [ self.d[self.west[i]-1] for i in range(6) ]

    def rollAll(self):
        for i in range(4):
            for i in range(4):
                self.roll('E')
                self.label.append((self.d[0], self.d[1], self.d[2]))
            self.roll('S')
        self.roll('E')
        self.roll('S')
        for i in range(4):
            self.roll('E')
            self.label.append((self.d[0], self.d[1], self.d[2]))
        self.roll('S')
        self.roll('S')
        for i in range(4):
            self.roll('E')
            self.label.append((self.d[0], self.d[1], self.d[2]))

    def getLabel(self):
        return set(self.label)

    def getDice(self):
        return self.d

s1= [ int(s) for s in input().split() ]
s2= [ int(s) for s in input().split() ]
dice1 = Dice(s1)
dice2 = Dice(s2)
dice1.rollAll()
dice2.rollAll()

l = dice1.getLabel()
l2 = dice2.getLabel()
if l == l2:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
import sys

# 立方体で数字が自由なさいころ
class Dice:
    def __init__(self, top, bottom, front, rear, right, left):
        self.top = top
        self.front = front
        self.right = right
        self.bottom = bottom
        self.rear = rear
        self.left = left

    def rotate_front(self):
        t, b, f, r = self.top, self.bottom, self.front, self.rear
        self.top = r
        self.bottom = f
        self.front = t
        self.rear = b

    def rotate_rear(self):
        t, b, f, r = self.top, self.bottom, self.front, self.rear
        self.top = f
        self.bottom = r
        self.front = b
        self.rear = t

    def rotate_right(self):
        t, b, r, l = self.top, self.bottom, self.right, self.left
        self.top = l
        self.bottom = r
        self.right = t
        self.left = b

    def rotate_left(self):
        t, b, r, l = self.top, self.bottom, self.right, self.left
        self.top = r
        self.bottom = l
        self.right = b
        self.left = t

    def get_tfr(self):
        return [self.top, self.front, self.right]

    def get_all(self):
        return (self.top, self.bottom, self.front, self.rear, self.right, self.left)

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")

def main():
    top, front, right, left, rear, bottom = map(int, input().split())
    top2, front2, right2, left2, rear2, bottom2 = map(int, input().split())
    d = Dice(top, bottom, front, rear, right, left)
    states = set()

    states.add(d.get_all())
    for _ in range(3):
        d.rotate_right()
        states.add(d.get_all())
    d.rotate_front()
    d.rotate_front()
    states.add(d.get_all())
    for _ in range(3):
        d.rotate_right()
        states.add(d.get_all())

    d.rotate_front()
    states.add(d.get_all())
    for _ in range(3):
        d.rotate_right()
        states.add(d.get_all())
    d.rotate_front()
    d.rotate_front()
    states.add(d.get_all())
    for _ in range(3):
        d.rotate_right()
        states.add(d.get_all())

    d.rotate_right()
    d.rotate_front()
    states.add(d.get_all())
    for _ in range(3):
        d.rotate_right()
        states.add(d.get_all())
    d.rotate_front()
    d.rotate_front()
    states.add(d.get_all())
    for _ in range(3):
        d.rotate_right()
        states.add(d.get_all())
    # print(tftor)

    if (top2, bottom2, front2, rear2, right2, left2) in states:
        print("Yes")
    else:
        print("No")

main()

Submission status: Accepted

Solution code:
dice1 = list(map(int, input().split()))
dice2 = list(map(int, input().split()))

flag = False

# ②W方向
for _ in range(4):
    temp = dice2[0]
    dice2[0] = dice2[2]
    dice2[2] = dice2[5]
    dice2[5] = dice2[3]
    dice2[3] = temp
    # ①水平右回り
    for _ in range(4):
        temp = dice2[1]
        dice2[1] = dice2[2]
        dice2[2] = dice2[4]
        dice2[4] = dice2[3]
        dice2[3] = temp
        
        if dice2 == dice1:
            flag = True
            
# ④N方向
for _ in range(4):
    temp = dice2[0]
    dice2[0] = dice2[1]
    dice2[1] = dice2[5]
    dice2[5] = dice2[4]
    dice2[4] = temp
    # ③水平右回り
    for _ in range(4):
        temp = dice2[1]
        dice2[1] = dice2[2]
        dice2[2] = dice2[4]
        dice2[4] = dice2[3]
        dice2[3] = temp
        
        if dice2 == dice1:
            flag = True
            
if flag:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
dice1=list(map(int,input().split()))
dice2=list(map(int,input().split()))

def E(ls):
    ls=[ls[3],ls[1],ls[0],ls[5],ls[4],ls[2]]
    return ls

def N(ls):
    ls=[ls[1],ls[5],ls[2],ls[3],ls[0],ls[4]]
    return ls

def R(ls):
    ls=[ls[0],ls[2],ls[4],ls[1],ls[3],ls[5]]
    return ls
    
dice1_ls=[dice1,]

for i in range(3):
    dice1=E(dice1)
    dice1_ls.append(dice1)
dice1=E(dice1)
dice1=N(dice1)
dice1_ls.append(dice1)
dice1=N(N(dice1))
dice1_ls.append(dice1)
for i in range(6):
    dice=dice1_ls[i]
    for j in range(3):
        dice=R(dice)
        dice1_ls.append(dice)
if dice2 in dice1_ls:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
def rotate(arr,i):
    if i=='W':
        arr=[arr[k-1] for k in [3,2,6,1,5,4]]
    if i=='E':
        arr=[arr[k-1] for k in [4,2,1,6,5,3]]
    if i=='N':
        arr=[arr[k-1] for k in [2,6,3,4,1,5]]
    if i=='S':
        arr=[arr[k-1] for k in [5,1,3,4,6,2]]
    return arr
arr=input().split()
deck=[]
for i in 'W'*4:
    arr=rotate(arr,i)
    for k in 'NNNN':
        arr=rotate(arr,k)
        deck.append(arr)
arr=rotate(arr,'N')
arr=rotate(arr,'W')
for k in 'NNNN':
    arr=rotate(arr,k)
    deck.append(arr)
arr=rotate(arr,'W')
arr=rotate(arr,'W')
for k in 'NNNN':
    arr=rotate(arr,k)
    deck.append(arr)
arr2=input().split()
if arr2 in deck:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
class Dice:
    
    def __init__(self, U, S, E, W, N, D):
        self.u, self.d = U, D
        self.e, self.w = E, W
        self.s, self.n = S, N       
    
    def roll(self, command):
        if command == 'E':
            self.e, self.u, self.w, self.d = self.u, self.w, self.d, self.e
        elif command == 'W':
            self.e, self.u, self.w, self.d = self.d, self.e, self.u, self.w
        elif command == 'S':
            self.s, self.u, self.n, self.d = self.u, self.n, self.d, self.s
        else:
            self.s, self.u, self.n, self.d = self.d, self.s, self.u, self.n


    def __eq__(self, other):

        other_hex = [other.u, other.s, other.e, other.w, other.n, other.d]
        self_hex = [self.u, self.s, self.e, self.w, self.n, self.d]
        if sorted(other_hex) != sorted(self_hex):
            print('No')
            return
        for i in 'NNNNENNNENNNWNNNWNNNENNN':
            self.roll(i)
            if other.u == self.u and other.s == self.s and other.e == self.e \
            and other.w == self.w and other.n == self.n and other.d == self.d:
                   print('Yes')
                   break
        else:
            print('No')

                


U, S, E, W, N, D = [int(i) for i in input().split()]
dice1 = Dice(U, S, E, W, N, D)
U, S, E, W, N, D = [int(i) for i in input().split()]
dice2 = Dice(U, S, E, W, N, D)
dice1 == dice2

Submission status: Accepted

Solution code:
class Dice:
    def __init__(self, label):
        self.label = label.copy()
    
    def rotateS(self):
        """[1, 2, 6, 5] -> [5, 1, 2, 6]"""
        t = self.label[1]
        self.label[1] = self.label[5]
        self.label[5] = self.label[6]
        self.label[6] = self.label[2]
        self.label[2] = t

    def rotateN(self):
        t = self.label[1]
        self.label[1] = self.label[2]
        self.label[2] = self.label[6]
        self.label[6] = self.label[5]
        self.label[5] = t
    
    def rotateW(self):
        t = self.label[1]
        self.label[1] = self.label[3]
        self.label[3] = self.label[6]
        self.label[6] = self.label[4]
        self.label[4] = t
    
    def rotateE(self):
        t = self.label[1]
        self.label[1] = self.label[4]
        self.label[4] = self.label[6]
        self.label[6] = self.label[3]
        self.label[3] = t

    def rotateR(self):
        t = self.label[3]
        self.label[3] = self.label[2]
        self.label[2] = self.label[4]
        self.label[4] = self.label[5]
        self.label[5] = t

    def rotateL(self):
        t = self.label[3]
        self.label[3] = self.label[5]
        self.label[5] = self.label[4]
        self.label[4] = self.label[2]
        self.label[2] = t

def debugprint(dice1, dice2, label=''):
    debug=False
    if (debug):
        print(label)
        print('dice1: {}'.format(dice1.label))
        print('dice2: {}'.format(dice2.label))
        print('')

def compare(dice1, dice2):
    if (dice1.label == dice2.label):
        return True
    else:
        return False

def verify(dice1, dice2):
    dice_t = Dice(dice2.label)
    numS = 0
    for i in range(0,4):
        numR = 0
        for _ in range(0,4):
            debugprint(dice1, dice_t)
            if (compare(dice1, dice_t)):
                return True
            dice_t.rotateR()
            numR += 1
        #print(numR)
        dice_t.rotateS()
        numS += 1
    #print(numS)

    dice_t.rotateE()
    for _ in range(0,4):
        debugprint(dice1, dice_t)
        if (compare(dice1, dice_t)):
            return True
        dice_t.rotateR()

    dice_t.rotateE()
    dice_t.rotateE()
    for _ in range(0,4):
        debugprint(dice1, dice_t)
        if (compare(dice1, dice_t)):
            return True
        dice_t.rotateR()

    return False


## Main

label1 = []
label1.append(-1)
label1[1:] = map(int,input().split())
dice1 = Dice(label1)
#print(dice1.label)

label2 = []
label2.append(-1)
label2[1:] = map(int,input().split())
dice2 = Dice(label2)
#print(dice2.label)

debugprint(dice1, dice2, 'before rotate')

label1.sort()
label2.sort()
if (label1 != label2):
    print("No")
    exit()

if (verify(dice1, dice2)):
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
D = [
    (1, 5, 2, 3, 0, 4), # 'U'
    (3, 1, 0, 5, 4, 2), # 'R'
    (4, 0, 2, 3, 5, 1), # 'D'
    (2, 1, 5, 0, 4, 3), # 'L'
]

*L1, = map(int, input().split())
*L2, = map(int, input().split())

p = (0, 0, 0, 1, 1, 2, 2, 3)*3
ok = 0
for k in p:
    if L1 == L2:
        ok = 1
    L2[:] = [L2[e] for e in D[k]]

print("Yes" if ok else "No")

Submission status: Accepted

Solution code:
import random

class Dice:
    def __init__(self):
        self.u=1
        self.w=2
        self.s=3
        self.e=4
        self.n=5
        self.d=6
        self.dic={"W":0,"S":1,"E":2,"N":3}
    
    def __init__(self,u,w,s,e,n,d):
        self.u=u
        self.w=w
        self.s=s
        self.e=e
        self.n=n
        self.d=d
        self.dic={"W":0,"S":1,"E":2,"N":3}

    def rot(self,way):
        if isinstance(way,str):
            way=self.dic[way]

        if way==0:
            c=self.u
            self.u=self.e
            self.e=self.d
            self.d=self.w
            self.w=c
        elif way==1:
            c=self.u
            self.u=self.n
            self.n=self.d
            self.d=self.s
            self.s=c
        elif way==2:
            c=self.u
            self.u=self.w
            self.w=self.d
            self.d=self.e
            self.e=c
        else :
            c=self.u
            self.u=self.s
            self.s=self.d
            self.d=self.n
            self.n=c

flag=0
lst=["W","S","E","N"]
u,s,e,w,n,d=map(int,input().split())
dice_1=Dice(u,w,s,e,n,d)
u,s,e,w,n,d=map(int,input().split())
dice_2=Dice(u,w,s,e,n,d)
for i in range(1000):
    if dice_1.u==dice_2.u and dice_1.w==dice_2.w and dice_1.s==dice_2.s and dice_1.e==dice_2.e and dice_1.n==dice_2.n and dice_1.d==dice_2.d:
        flag=1
    dice_1.rot(random.choice(lst))
if flag==1:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
class Dice:
    def __init__(self, top, front, right, left, back, bottom):
        self.TOP = top
        self.BOTTOM = bottom
        self.FRONT = front
        self.BACK = back
        self.LEFT = left
        self.RIGHT = right
    
    def move(self, direction):
        if direction == "N":
            self.move_N()
        elif direction == "E":
            self.move_E()
        elif direction == "S":
            self.move_S()
        elif direction == "W":
            self.move_W()
        elif direction == "SIDE":
            self.move_SIDE()
        else:
            raise Exception
    
    def move_N(self):
        tmp = self.TOP
        self.TOP = self.FRONT
        self.FRONT = self.BOTTOM
        self.BOTTOM = self.BACK
        self.BACK = tmp

    def move_S(self):
        tmp = self.TOP
        self.TOP = self.BACK
        self.BACK = self.BOTTOM
        self.BOTTOM = self.FRONT
        self.FRONT = tmp
        
    def move_W(self):
        tmp = self.TOP
        self.TOP = self.RIGHT
        self.RIGHT = self.BOTTOM
        self.BOTTOM = self.LEFT
        self.LEFT = tmp

    def move_E(self):
        tmp = self.TOP
        self.TOP = self.LEFT
        self.LEFT = self.BOTTOM
        self.BOTTOM = self.RIGHT
        self.RIGHT = tmp
    
    def move_SIDE(self):
        tmp = self.FRONT
        self.FRONT = self.RIGHT
        self.RIGHT = self.BACK
        self.BACK = self.LEFT
        self.LEFT = tmp

def is_same():
    for _ in range(4):
        dice.move("SIDE")
        for _ in range(4):
            dice.move("N")
            if dice.TOP == dice2.TOP and dice.FRONT == dice2.FRONT \
                and dice.RIGHT == dice2.RIGHT and dice.LEFT == dice2.LEFT \
                and dice.BACK == dice2.BACK and dice.BOTTOM == dice2.BOTTOM:
                return True
        for _ in range(4):
            dice.move("E")
            if dice.TOP == dice2.TOP and dice.FRONT == dice2.FRONT \
                and dice.RIGHT == dice2.RIGHT and dice.LEFT == dice2.LEFT \
                and dice.BACK == dice2.BACK and dice.BOTTOM == dice2.BOTTOM:
                return True
    return False
    
top, front, right, left, back, bottom = map(int,input().split())
dice = Dice(top, front, right, left, back, bottom)
top2, front2, right2, left2, back2, bottom2 = map(int,input().split())
dice2 = Dice(top2, front2, right2, left2, back2, bottom2)

if is_same():
    #print(dice.TOP, dice.FRONT, dice.RIGHT, dice.LEFT, dice.BACK, dice.BOTTOM)
    #print(dice2.TOP, dice2.FRONT, dice2.RIGHT, dice2.LEFT, dice2.BACK, dice2.BOTTOM)
    print("Yes")
else:
    #print(dice.TOP, dice.FRONT, dice.RIGHT, dice.LEFT, dice.BACK, dice.BOTTOM)
    #print(dice2.TOP, dice2.FRONT, dice2.RIGHT, dice2.LEFT, dice2.BACK, dice2.BOTTOM)
    print("No")

Submission status: Accepted

Solution code:
class Dice():
    def __init__(self):
        self.number = [i for i in range(6)]
        self.work = [i for i in range(6)]
    def setNumber(self,n0,n1,n2,n3,n4,n5):
        self.number[0] = n0
        self.number[1] = n1
        self.number[2] = n2
        self.number[3] = n3
        self.number[4] = n4
        self.number[5] = n5
    def roll(self,loc):
        for i in range(6):
            self.work[i] = self.number[i]
        if loc == 'E':
            self.setNumber(self.work[3],self.work[1],self.work[0],self.work[5],self.work[4],self.work[2])
        elif loc == 'N':
            self.setNumber(self.work[1],self.work[5],self.work[2],self.work[3],self.work[0],self.work[4])
        elif loc == 'S':
            self.setNumber(self.work[4],self.work[0],self.work[2],self.work[3],self.work[5],self.work[1])
        elif loc == 'W':
            self.setNumber(self.work[2],self.work[1],self.work[5],self.work[0],self.work[4],self.work[3])
dice1 = Dice()
table1 = list(map(int,input().split()))
dice1.setNumber(table1[0], table1[1], table1[2], table1[3], table1[4], table1[5])
dice2 = Dice()
table2 = list(map(int,input().split()))
dice2.setNumber(table2[0], table2[1], table2[2], table2[3], table2[4], table2[5])
for loc in "NNNNWNNNWNNNENNNENNNWNNN":
  dice2.roll(loc)
  if dice2.number==dice1.number:
    print("Yes")
    exit()
print("No")

Submission status: Accepted

Solution code:
class dice():
    def __init__(self):
        self.number = [i for i in range(6)]
        self.work = [i for i in range(6)]
    
    def setnum(self,s):
        self.number = s

    def kai(self,h):
        tmp = self.number
        if h == 'E':
            self.number = [tmp[3],tmp[1],tmp[0],tmp[5],tmp[4],tmp[2]]
        elif h == 'S':
            self.number = [tmp[4],tmp[0],tmp[2],tmp[3],tmp[5],tmp[1]]
        elif h == 'W':
            self.number = [tmp[2],tmp[1],tmp[5],tmp[0],tmp[4],tmp[3]]
        elif h == 'N':
            self.number = [tmp[1],tmp[5],tmp[2],tmp[3],tmp[0],tmp[4]]

    def Qright(self,up,flont,num):
        uf = (up,flont)
        if uf == (num[1],num[2]) or uf ==(num[2],num[4]) or uf ==(num[4],num[3]) or uf ==(num[3],num[1]):
            ans = num[0]
        elif uf == (num[0],num[3]) or uf ==(num[3],num[5]) or uf ==(num[5],num[2]) or uf ==(num[2],num[0]):
            ans = num[1]
        elif uf == (num[0],num[1]) or uf ==(num[1],num[5]) or uf ==(num[5],num[4]) or uf ==(num[4],num[0]):
            ans = num[2]
        elif uf == (num[0],num[4]) or uf ==(num[4],num[5]) or uf ==(num[5],num[1]) or uf ==(num[1],num[0]):
            ans = num[3]
        elif uf == (num[0],num[2]) or uf ==(num[2],num[5]) or uf ==(num[5],num[3]) or uf ==(num[3],num[0]):
            ans = num[4]
        elif uf == (num[1],num[3]) or uf ==(num[3],num[4]) or uf ==(num[4],num[2]) or uf ==(num[2],num[1]):
            ans = num[5]
        print(ans)




num = list(map(int,input().split()))
#kaitenn = input()
testall = 'NNNNENNNNENNNNENNNNENWNNNNEENNNN'
#q = int(input())
num2 = list(map(int,input().split()))
dice = dice()
dice.setnum(num)
for i in range(len(testall)):
#    up,flont = map(int,input().split())
#    dice.Qright(up,flont,num)
    dice.kai(testall[i])
    if dice.number == num2:
        print("Yes")
        break
    if i == len(testall)-1:
        print("No")
#print(dice.number[0])

Submission status: Accepted

Solution code:
import random

dice_a = list(map(int, input().split()))
dice_b = list(map(int, input().split()))


class Dice():
    def __init__(self, dice, directions):
        self.dice = dice
        self.directions = directions

    def roll(self):
        for direction in self.directions:
            NS = [0, 1, 5, 4]
            WE = [0, 2, 5, 3]
            copy_dice = self.dice[:]

            if direction == 'N':
                for j in range(4):
                    self.dice[NS[j]] = copy_dice[NS[j-3]]
            elif direction == 'S':
                for j in range(4):
                    self.dice[NS[j]] = copy_dice[NS[j-1]]
            elif direction == 'W':
                for j in range(4):
                    self.dice[WE[j]] = copy_dice[WE[j-3]]
            else:
                for j in range(4):
                    self.dice[WE[j]] = copy_dice[WE[j-1]]

        return self.dice


def check_equal(dice_1, dice_2):
    for i in range(777):
        dice_A = Dice(dice_1, random.choice(['N', 'S', 'W', 'E']))

        if dice_A.roll() == dice_2:
            print('Yes')
            break

    else:
        print('No')

check_equal(dice_a, dice_b)

Submission status: Accepted

Solution code:
#coding: utf-8

dirc = ((0,), (4, 0, 2, 3, 5, 1), (3, 1, 0, 5, 4, 2),
(2, 1, 5, 0, 4, 3), (1, 5, 2, 3, 0, 4), (5, 4, 2, 3, 1, 0))
sideNum = (1, 2, 4, 3)

labelA = list(map(int, input().split()))
labelB = list(map(int, input().split()))

for i in labelB:
    if labelA.count(i) != labelB.count(i):
        print('No')
        exit()

for i in range(6):
    labelC = [0 for k in range(6)]
    if i == 0:
        labelC = labelA[:]
    else:
        for j in range(6):
            labelC[dirc[i][j]] = labelA[j]
    if labelB[0] == labelC[0] and labelB[5] == labelC[5]:
        sideB = ''
        sideC = ''
        for j in sideNum:
            sideB += str(labelB[j])
            sideC += str(labelC[j])
        sideC += sideC
        if sideB in sideC:
            print('Yes')
            exit()
print('No')

Submission status: Accepted

Solution code:
class Dice:
    def __init__(self, default = [1, 2, 3, 4, 5, 6]):
        self.d = default

    def e(self):
        self.d[0], self.d[2], self.d[3], self.d[5] = self.d[3], self.d[0], self.d[5], self.d[2]

    def w(self):
        self.d[0], self.d[2], self.d[3], self.d[5] = self.d[2], self.d[5], self.d[0], self.d[3]

    def n(self):
        self.d[0], self.d[1], self.d[4], self.d[5] = self.d[1], self.d[5], self.d[0], self.d[4]

    def s(self):
        self.d[0], self.d[1], self.d[4], self.d[5] = self.d[4], self.d[0], self.d[5], self.d[1]

    def r(self):
        self.d[1], self.d[2], self.d[3], self.d[4] = self.d[3], self.d[1], self.d[4], self.d[2]

    def top(self):
        return self.d[0]

    def forward(self):
        return self.d[1]

    def right(self):
        return self.d[2]

    def bottom(self):
        return self.d[5]

    def forTop(self, num):  #ある目がトップd[0]になるように回転させる。トップ以外の状態は知らん。
        for i in range(4):
            if self.top() == num:
                break
            self.e()
        else:
            for j in range(3):
                if self.top() == num:
                    break
                self.s()
    def same(self, dice):
        if self.d == dice.d:
            return True


def main():
    a_ = [int(i) for i in input().split()]
    b_ = [int(i) for i in input().split()]
    if not sorted(a_) == sorted(b_):
        print('No')
        return
    a = Dice(a_)
    b = Dice(b_)
    for i in range(4):
        for j in range(4):
            if b.same(a):
                print('Yes')
                return
            else:
                b.e()
        b.s()
    for i in range(4):
        for j in range(4):
            if b.same(a):
                print('Yes')
                return
            else:
                b.e()
        b.r()
    for i in range(4):
        for j in range(4):
            if b.same(a):
                print('Yes')
                return
            else:
                b.s()
        b.r()


    print('No')
    return




if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
class Dice:
    #f[]はUSEWNDの順，添字はU:0,S:1,E:2,W:3,N:4,D:5
    def __init__(self,l):
        self.f=l
        
    def __str__(self):
        l=self.f
        s=f'[U:{l[0]},S:{l[1]},E:{l[2]},W:{l[3]},N:{l[4]},D:{l[5]}]'
        return(s)
       
    def roll(self,c):
        if c=='N':
            ni=[1,5,2,3,0,4]
        elif c=='S':
            ni=[4,0,2,3,5,1]
        elif c=='E':
            ni=[3,1,0,5,4,2]
        elif c=='W':
            ni=[2,1,5,0,4,3]
        self.f=[self.f[j] for j in ni]
    
    def rotate(self,r):
        if r==+1: #Uから見て反時計(西)回り
            ni=[0,3,1,4,2,5]
        elif r==-1: #Uから見て時計(東)周り
            ni=[0,2,4,1,3,5]
        self.f=[self.f[j] for j in ni]

    def patterns(self):
        fs=[]
        for i in range(6):
            if i%2==0:
                self.roll('N')
            else:
                self.roll('E')
            for j in range(4):
                self.rotate(+1)
                fs.append(self.f)
        return fs
        
    def lookEast(self,l):
        for f in self.patterns():
            if f[0]==l[0] and f[1]==l[1]:
                return f[2]
    
    def equals(self,d):
        for f in self.patterns():
            if f==d.f:
                return True
        return False

print('Yes' if Dice(list(map(int,input().split()))).equals(Dice(list(map(int,input().split())))) else 'No')

Submission status: Accepted

Solution code:
import copy
import sys
class Dice():
    def __init__(self, t, s, e, w, n, b):
        self.a = [t, s, e, w, n, b]
        self.a_org = copy.deepcopy(self.a)

    def reset(self):
        self.a = copy.deepcopy(self.a_org)
    
    def shake(self, me):
        if me == 'S':
            self.b = [self.a[int(i)] for i in '402351']
            self.a = self.b
        elif me == 'N':
            self.b = [self.a[int(i)] for i in '152304']
            self.a = self.b
        if me == 'W':
            self.b = [self.a[int(i)] for i in '215043']
            self.a = self.b
        if me == 'E':
            self.b = [self.a[int(i)] for i in '310542']
            self.a = self.b  
    def get(self, dir):
        if dir == 't': return self.a[0]
        elif dir == 's': return self.a[1]
        elif dir == 'e': return self.a[2]
        elif dir == 'w': return self.a[3]
        else: print('input err', dir)
    def front(self, f):
        self.reset()
        if f == 0:self.shake('S')
        elif f == 4:self.shake('S');self.shake('S')
        elif f == 3:self.shake('E');self.shake('S')
        elif f == 2:self.shake('W');self.shake('S')
        elif f == 5:self.shake('N')

n1 = list(map(int, input().split()))
n2 = list(map(int, input().split()))

d1 = Dice(*n1)
d2 = Dice(*n2)

for i in range(6):
    if d1.a == d2.a:
        print('Yes')
        sys.exit()
    else:
        d2.front(i)
        if d1.a == d2.a:
            print('Yes')
            sys.exit()
    for _ in range(3):
        d2.shake('W')
        if d1.a == d2.a:
            print('Yes')
            sys.exit()
        
print('No')

Submission status: Accepted

Solution code:
class Dice:
    def __init__(self,list):
        self.list = []
        for i in range(6):
            self.list.append(list[i])

    def rotate(self,dir):
        if dir == "N":
            self.list[0], self.list[1], self.list[5], self.list[4] = self.list[1], self.list[5], self.list[4], self.list[0]
        elif dir == "S":
            self.list[0], self.list[4], self.list[5], self.list[1] = self.list[4], self.list[5], self.list[1], self.list[0]
        elif dir == "W":
            self.list[0], self.list[3], self.list[5], self.list[2] = self.list[2], self.list[0], self.list[3], self.list[5]
        elif dir == "E":
            self.list[0], self.list[3], self.list[5], self.list[2] = self.list[3], self.list[5], self.list[2], self.list[0]
        elif dir == "H":
            self.list[1], self.list[2], self.list[4], self.list[3] = self.list[2], self.list[4], self.list[3], self.list[1]
        elif dir =="V":
            self.list[0], self.list[3], self.list[5], self.list[2] = self.list[3], self.list[5], self.list[2], self.list[0]
        else:
            pass

    def show(self):
        print("D:{}".format(repr(self.list)))

    def isface(self,f):
        if f in self.list:
            return True
        else:
            return False

    def isSameface(self,b):
        for i in range(len(self.list)):
            if self.list[i] != b.list[i]:
                return False
        return True

    def isSame(self,b):
        
        for c in "ZHHHWHHHEHHHEHHHWHHHWHHH":
            b.rotate(c)
            if self.isSameface(b):
                return True
        return False


def main():
    l = [int(x) for x in input().split()]
    k = [int(x) for x in input().split()]
    a = Dice(l)
    b = Dice(k)

    if a.isSame(b):
        print("Yes")
    else:
        print("No")


if __name__  == '__main__':
    main()

Submission status: Accepted

Solution code:
pattern_list =[[0,1,2,3,4,5],[0,2,4,1,3,5],[0,4,3,2,1,5],[0,3,1,4,2,5],[1,2,0,5,3,4],[1,5,2,3,0,4],[1,3,5,0,2,4],[1,0,3,2,5,4],[2,0,1,4,5,3],[2,4,0,5,1,3],[2,5,4,1,0,3],[2,1,5,0,4,3],[3,0,4,1,5,2],[3,1,0,5,4,2],[3,5,1,4,0,2],[3,4,5,0,1,2],[4,2,5,0,3,1],[4,0,2,3,5,1],[4,3,0,5,2,1],[4,5,3,2,0,1],[5,1,3,2,4,0],[5,2,1,4,3,0],[5,4,2,3,1,0],[5,3,4,1,2,0]]

dice_a_list = list(map(int,input().split()))
dice_b_list = list(map(int,input().split()))

dice_c_list =[0,0,0,0,0,0]
cnt = 0
for i in range(24):
	for j in range(6):
		dice_c_list[j]=  dice_a_list[pattern_list[i][j]]
	if dice_c_list == dice_b_list:
		cnt =1
if cnt==0:
	print("No")
else:
	print("Yes")