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:
# -*- coding: utf-8 -*-

import sys
import os
import math


dice0 = list(map(int, input().split()))
dice1 = list(map(int, input().split()))

def dice_roll(dice, c):
    copy = dice[:]
    if c == 'E':
        dice[2] = copy[0]
        dice[5] = copy[2]
        dice[3] = copy[5]
        dice[0] = copy[3]
    elif c == 'N':
        dice[0] = copy[1]
        dice[4] = copy[0]
        dice[5] = copy[4]
        dice[1] = copy[5]
        pass
    elif c == 'S':
        dice[1] = copy[0]
        dice[0] = copy[4]
        dice[4] = copy[5]
        dice[5] = copy[1]
    elif c == 'W':
        dice[0] = copy[2]
        dice[2] = copy[5]
        dice[5] = copy[3]
        dice[3] = copy[0]
    # Y???????????¢
    elif c == 'R':
        dice[2] = copy[1]
        dice[4] = copy[2]
        dice[3] = copy[4]
        dice[1] = copy[3]
    return dice


def check():
    global dice0
    global dice1

    # up???????????????
    num = 0
    while dice0[0] != dice1[0]:
        if num % 2 == 0:
            dice0 = dice_roll(dice0, 'E')
        else:
            dice0 = dice_roll(dice0, 'N')
        num += 1
        if num > 10:
            return False

    # front???????????????
    num = 0
    while dice0[1] != dice1[1]:
        dice0 = dice_roll(dice0, 'R')
        num += 1
        if num > 10:
            return False

    if dice0[2] == dice1[2] and dice0[3] == dice1[3] and dice0[4] == dice1[4] and dice0[5] == dice1[5]:
        return True
    else:
        return False

result = check()
if result:
    print('Yes')
else:
    # ????????????
    dice0 = dice_roll(dice0, 'N')
    result = check()
    if result:
        print('Yes')
    else:
        print('No')

Submission status: Accepted

Solution code:
class dice:
    def __init__(self,label):
        self.spots = label

    def roll(self,way):
        if way == "N":
            self.spots = [self.spots[1],self.spots[5],self.spots[2],self.spots[3],self.spots[0],self.spots[4]]
        if way == "E":
            self.spots = [self.spots[3],self.spots[1],self.spots[0],self.spots[5],self.spots[4],self.spots[2]]
        if way == "W":
            self.spots = [self.spots[2],self.spots[1],self.spots[5],self.spots[0],self.spots[4],self.spots[3]]
        if way == "S":
            self.spots = [self.spots[4],self.spots[0],self.spots[2],self.spots[3],self.spots[5],self.spots[1]]
    def output(self):
        return self.spots


dice_1 = list(map(int,input().split()))
label = list(map(int,input().split()))
dice_2 = []

rotation = dice(label)
for i in range(3):
    dice_2.append(rotation.output())
    for j in range(3):
        rotation.roll("E")
        dice_2.append(rotation.output())
    rotation.roll("N")

rotation.roll("N")
rotation.roll("N")

for i in range(3):
    dice_2.append(rotation.output())
    for j in range(3):
        rotation.roll("W")
        dice_2.append(rotation.output())
    rotation.roll("N")

if dice_1 in dice_2:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
class Dice:
    """????????????????????????"""
    def __init__(self, s):
        self.s = [0 for _ in range(6)]
        self.s[0] = s[0]
        self.s[1] = s[1]
        self.s[2] = s[2]
        self.s[3] = s[3]
        self.s[4] = s[4]
        self.s[5] = s[5]

    def roll(self, direction):          # ???????????????????§??????¢????????¢
        temp = self.s[0]
        if direction == "E":
            self.s[0] = self.s[3]
            self.s[3] = self.s[5]
            self.s[5] = self.s[2]
            self.s[2] = temp
        elif direction == "N":
            self.s[0] = self.s[1]
            self.s[1] = self.s[5]
            self.s[5] = self.s[4]
            self.s[4] = temp
        elif direction == "S":
            self.s[0] = self.s[4]
            self.s[4] = self.s[5]
            self.s[5] = self.s[1]
            self.s[1] = temp
        elif direction == "W":
            self.s[0] = self.s[2]
            self.s[2] = self.s[5]
            self.s[5] = self.s[3]
            self.s[3] = temp

    def setposition(self, a, b):
        for _ in range(6):
            if self.s[0] == a:
                break
            self.roll("N")
            if self.s[0] == a:
                break
            self.roll("E")
        for _ in range(6):
            if self.s[1] == b:
                break
            self.roll("N")
            self.roll("E")
            self.roll("S")


s = list(map(int, input().split()))
dice1 = Dice(s)
s = list(map(int, input().split()))
dice2 = Dice(s)

answer = "No"
for _ in range(3):
    for _ in range(4):
        dice1.roll("N")
        dice1.roll("E")
        dice1.roll("S")
        if dice1.s == dice2.s:
            answer = "Yes"
    dice1.roll("N")
    for _ in range(4):
        dice1.roll("N")
        dice1.roll("E")
        dice1.roll("S")
        if dice1.s == dice2.s:
            answer = "Yes"
    dice1.roll("E")

print(answer)

Submission status: Accepted

Solution code:
#ITP1_11-C Dice 3
store=[]
str=["N","S","E","W"]
rep={
    "N":[4,0,2,3,5,1],
    "S":[1,5,2,3,0,4],
    "E":[2,1,5,0,4,3],
    "W":[3,1,0,5,4,2]
}

def rotate_dice(b,s):
    result = [0,0,0,0,0,0]
    for i in range(6):
        result[i]=b[rep[s][i]]
    return result
    
def check(a,b):
    if (b in store)==False:
        store.append(b)
        for s in str:
            check(a,rotate_dice(b,s))

a = input().split(" ")
b = input().split(" ")
r = check(a,b)
if a in store:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

    def setState(self, li):  # [top, S, E, W, N, under]
        self.state = li

    def move(self, str_direction):
        if str_direction == "N":
            self.state = [self.state[1], self.state[5],self.state[2],
                          self.state[3], self.state[0], self.state[4]]
        if str_direction == "W":
            self.state = [self.state[2], self.state[1], self.state[5],
                          self.state[0], self.state[4], self.state[3]]
        if str_direction == "E":
            self.state = [self.state[3], self.state[1], self.state[0],
                          self.state[5], self.state[4], self.state[2]]
        if str_direction == "S":
            self.state = [self.state[4], self.state[0], self.state[2],
                          self.state[3], self.state[5], self.state[1]]

    def rotate(self):
        self.state = [self.state[0], self.state[2], self.state[4],
                      self.state[1], self.state[3], self.state[5]]

    def sameDice1(self, dice1):
        set1 = list()
        for _ in range(4):
            for __ in range(4):
                set1.append(self.state)
                self.rotate()
            self.move("N")
        self.move("E")
        for _ in range(4):
            set1.append(self.state)
            self.rotate()
        self.move("E")
        self.move("E")
        for _ in range(4):
            set1.append(self.state)
            self.rotate()
        if dice1.state in set1:
            return "Yes"
        return "No"


def main():
    myd1, myd2 = Dice(), Dice()
    myd1.setState(list(map(int, input().split())))
    myd2.setState(list(map(int, input().split())))
    print(myd1.sameDice1(myd2))
    return

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
def main():
    labels1 = list(map(int, input().split(' ')))
    labels2 = list(map(int, input().split(' ')))

    dice1 = Dice(labels1)
    dice2 = Dice(labels2)

    print('Yes' if equals(dice1, dice2) else 'No')

def equals(d1, d2):
    for i in range(4):
        for j in range(4):
            if d1.equals(d2):
                return True
            d2.toE()
        d2.toN()

    d2.toE().toN()

    for i in range(2):
        for j in range(4):
            if d1.equals(d2):
                return True
            d2.toE()
        d2.toN().toN()

    return False

class Dice:
    def __init__(self, labels):
        self.labels = labels

        self._tb = (0, 5)
        self._fb = (1, 4)
        self._lr = (3, 2)

    def toN(self):
        tb = self._tb
        self._tb = self._fb
        self._fb = tuple(reversed(tb))

        return self

    def toS(self):
        tb = self._tb
        self._tb = tuple(reversed(self._fb))
        self._fb = tb

        return self

    def toW(self):
        tb = self._tb
        self._tb = tuple(reversed(self._lr))
        self._lr = tb

        return self

    def toE(self):
        tb = self._tb
        self._tb = self._lr
        self._lr = tuple(reversed(tb))

        return self

    def get_top(self):
        return self.labels[self._tb[0]]

    def get_bottom(self):
        return self.labels[self._tb[1]]

    def get_front(self):
        return self.labels[self._fb[0]]

    def get_back(self):
        return self.labels[self._fb[1]]

    def get_left(self):
        return self.labels[self._lr[0]]

    def get_right(self):
        return self.labels[self._lr[1]]

    top    = property(get_top)
    bottom = property(get_bottom)
    front  = property(get_front)
    back   = property(get_back)
    left   = property(get_left)
    right  = property(get_right)

    def equals(self, other):
        if not (self.top == other.top and self.bottom == other.bottom):
            return False

        if not (self.front == other.front and self.back == other.back):
            return False

        if not (self.left == other.left and self.right == other.right):
            return False

        return True

    def __str__(self):
        return str([self.top, self.front, self.right, self.left, self.back, self.bottom])

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
x = list(map(int, input().split()))
y = list(map(int, input().split()))
z = [[0, 1, 2, 3], [0, 2, 1, 1], [1, 0, 2, 1], [2, 0, 1, 0], [1, 2, 0, 0], [2, 1, 0, 1]]
succeed = False
for i in range(6):
    match = True
    order = [0, 0, 0]
    for j in range(3):
        if {x[j], x[-j-1]} != {y[z[i][j]], y[-z[i][j]-1]}:
            match = False
            break
        else:
            if x[j] == y[z[i][j]]:
                order[j] = 1
                if x[j] == x[-j-1]:
                    order[j] = 2
    if match:
        if order[0] == 2 or order[1] == 2 or order[2] == 2:
            succeed = True
            break
        if z[i][3] == 0 or z[i][3] == 3:
            if sum(order) % 2:
                succeed = True
                break
        if z[i][3] == 1:
            if not sum(order) % 2:
                succeed = True
                break
if succeed:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
x = list(map(int, input().split()))
y = list(map(int, input().split()))
z = [[0, 1, 2, 3], [0, 2, 1, 1], [1, 0, 2, 1], [2, 0, 1, 0], [1, 2, 0, 0], [2, 1, 0, 1]]
succeed = False
for i in range(6):
    match = True
    order = [0, 0, 0]
    for j in range(3):
        if {x[j], x[-j-1]} != {y[z[i][j]], y[-z[i][j]-1]}:
            match = False
            break
        else:
            if x[j] == y[z[i][j]]:
                order[j] = 1
                if x[j] == x[-j-1]:
                    order[j] = 2
    if match:
        if 2 in order:
            succeed = True
            break
        if z[i][3] == 0 or z[i][3] == 3:
            if sum(order) % 2:
                succeed = True
                break
        if z[i][3] == 1:
            if not sum(order) % 2:
                succeed = True
                break
if succeed:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
x = list(map(int, input().split()))
y = list(map(int, input().split()))
z = [[0, 1, 2, 3], [0, 2, 1, 1], [1, 0, 2, 1], [2, 0, 1, 0], [1, 2, 0, 0], [2, 1, 0, 1]]
succeed = False
for i in range(6):
    match = True
    order = [0, 0, 0]
    for j in range(3):
        if {x[j], x[-j-1]} != {y[z[i][j]], y[-z[i][j]-1]}:
            match = False
            break
        else:
            if x[j] == y[z[i][j]]:
                order[j] = 1
                if x[j] == x[-j-1]:
                    order[j] = 2
    if match:
        if 2 in order:
            succeed = True
            break
        if (z[i][3] == 0 or z[i][3] == 3) and sum(order) % 2:
            succeed = True
            break
        if z[i][3] == 1 and not sum(order) % 2:
            succeed = True
            break
if succeed:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
x = list(map(int, input().split()))
y = list(map(int, input().split()))
z = [[0, 1, 2, 3], [0, 2, 1, 1], [1, 0, 2, 1], [2, 0, 1, 0], [1, 2, 0, 0], [2, 1, 0, 1]]
succeed = False
for i in range(6):
    match = True
    order = [0, 0, 0]
    for j in range(3):
        if {x[j], x[-j-1]} != {y[z[i][j]], y[-z[i][j]-1]}:
            match = False
            break
        if x[j] == y[z[i][j]]:
            order[j] = 1
            if x[j] == x[-j-1]:
                order[j] = 2 
    if match:
        if 2 in order:
            succeed = True
            break
        if (z[i][3] == 0 or z[i][3] == 3) and sum(order) % 2:
            succeed = True
            break
        if z[i][3] == 1 and not sum(order) % 2:
            succeed = True
            break
if succeed:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
x = list(map(int, input().split()))
y = list(map(int, input().split()))
z = [[0, 1, 2, 3], [0, 2, 1, 1], [1, 0, 2, 1], [2, 0, 1, 0], [1, 2, 0, 0], [2, 1, 0, 1]] 
succeed = False
for i in range(6):
    order = [0, 0, 0]
    for j in range(3):
        if {x[j], x[-j-1]} != {y[z[i][j]], y[-z[i][j]-1]}:
            break
        if x[j] == y[z[i][j]]:
            order[j] = 1 
            if x[j] == x[-j-1]:
                order[j] = 2 
    else:
        if 2 in order:
            succeed = True
            break
        if (z[i][3] == 0 or z[i][3] == 3) and sum(order) % 2:
            succeed = True
            break
        if z[i][3] == 1 and not sum(order) % 2:
            succeed = True
            break
if succeed:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
x = list(map(int, input().split()))
y = list(map(int, input().split()))
z = [[0, 1, 2, 3], [0, 2, 1, 1], [1, 0, 2, 1], [2, 0, 1, 0], [1, 2, 0, 0], [2, 1, 0, 1]]
for i in range(6):
    order = [0, 0, 0]
    for j in range(3):
        if {x[j], x[-j-1]} != {y[z[i][j]], y[-z[i][j]-1]}:
            break
        if x[j] == y[z[i][j]]:
            order[j] = 1
            if x[j] == x[-j-1]:
                order[j] = 2
    else:
        if 2 in order:
            print('Yes')
            break
        if (z[i][3] == 0 or z[i][3] == 3) and sum(order) % 2:
            print('Yes')
            break
        if z[i][3] == 1 and not sum(order) % 2:
            print('Yes')
            break
else:
    print('No')

Submission status: Accepted

Solution code:
x = list(map(int, input().split()))
y = list(map(int, input().split()))
z = [[0, 1, 2, 3], [0, 2, 1, 1], [1, 0, 2, 1], [2, 0, 1, 0], [1, 2, 0, 0], [2, 1, 0, 1]]
for i in range(6):
    order = [0, 0, 0]
    for j in range(3):
        if {x[j], x[-j-1]} != {y[z[i][j]], y[-z[i][j]-1]}:
            break
        if x[j] == y[z[i][j]]:
            order[j] = 1
            if x[j] == x[-j-1]:
                order[j] = 2
    else:
        if 2 in order:
            print('Yes')
            break
        if z[i][3] in [0, 3] and sum(order) % 2:
            print('Yes')
            break
        if z[i][3] == 1 and not sum(order) % 2:
            print('Yes')
            break
else:
    print('No')

Submission status: Accepted

Solution code:
x = list(map(int, input().split()))
y = list(map(int, input().split()))
z = [[0, 1, 2, 3], [0, 2, 1, 1], [1, 0, 2, 1], [2, 0, 1, 0], [1, 2, 0, 0], [2, 1, 0, 1]]
for i in range(6):
    order = [0, 0, 0]
    for j in range(3):
        if x[j] == y[z[i][j]] and x[-j-1] == y[-z[i][j]-1]:
            if x[j] == x[-j-1]:
                order[j] = 2
        elif x[j] == y[-z[i][j]-1] and x[-j-1] == y[z[i][j]]:
            order[j] = 1
        else:
            break
    else:
        if 2 in order:
            print('Yes')
            break
        if z[i][3] in [0, 3] and not sum(order) % 2:
            print('Yes')
            break
        if z[i][3] == 1 and sum(order) % 2:
            print('Yes')
            break
else:
    print('No')

Submission status: Accepted

Solution code:
x = list(map(int, input().split()))
y = list(map(int, input().split()))
z = [[0, 1, 2, 1], [0, 2, 1, 0], [2, 1, 0, 0], [1, 0, 2, 0], [2, 0, 1, 1], [1, 2, 0, 1]]
for i in range(6):
    order = [0, 0, 0]
    for j in range(3):
        if {x[j], x[-j-1]} != {y[z[i][j]], y[-z[i][j]-1]}:
            break
        if x[j] == y[z[i][j]]:
            order[j] = 1
            if x[j] == x[-j-1]:
                order[j] = 2
    else:
        if 2 in order:
            print('Yes')
            break
        if z[i][3] == sum(order) % 2:
            print('Yes')
            break
else:
    print('No')

Submission status: Accepted

Solution code:
x = list(map(int, input().split()))
y = list(map(int, input().split()))
z = [[0, 1, 2, 1], [0, 2, 1, 0], [2, 1, 0, 0], [1, 0, 2, 0], [2, 0, 1, 1], [1, 2, 0, 1]]
for i in range(6):
    order = [0, 0, 0]
    for j in range(3):
        if {x[j], x[-j-1]} != {y[z[i][j]], y[-z[i][j]-1]}:
            break
        if x[j] == y[z[i][j]]:
            order[j] = 1
            if x[j] == x[-j-1]:
                order[j] = 2
    else:
        if 2 in order or z[i][3] == sum(order) % 2:
            print('Yes')
            break
else:
    print('No')

Submission status: Accepted

Solution code:
class Dice:
    def __init__(self,t,f,r,l,ba,bo):
        self.t = t
        self.f = f
        self.r = r
        self.l = l
        self.ba = ba
        self.bo = bo
    
    def E(self):
        a = self.t
        b = self.r
        c = self.bo
        d = self.l
        self.r = a
        self.bo = b
        self.l = c
        self.t = d
    
    def N(self):
        a = self.t
        b = self.ba
        c = self.bo
        d = self.f
        self.ba = a
        self.bo = b
        self.f = c
        self.t = d
    
    def S(self):
        a = self.t
        b = self.ba
        c = self.bo
        d = self.f
        self.f = a
        self.t = b
        self.ba = c
        self.bo = d
    
    def W(self):
        a = self.t
        b = self.r
        c = self.bo
        d = self.l
        self.l = a
        self.t = b
        self.r = c
        self.bo = d

s = input().split(" ")
dice1 = Dice(s[0],s[1],s[2],s[3],s[4],s[5])
s = input().split(" ")
dice2 = Dice(s[0],s[1],s[2],s[3],s[4],s[5])

if dice1.t == dice2.f:
    dice2.N()
elif dice1.t == dice2.r:
    dice2.W()
elif dice1.t == dice2.l:
    dice2.E()
elif dice1.t == dice2.ba:
    dice2.S()
elif dice1.t == dice2.bo:
    dice2.E()
    dice2.E()
if dice1.bo != dice2.bo:
    dice2.N()
    for i in range(4):
        if dice1.t == dice2.t and dice1.bo == dice2.bo:
            break
        dice2.E()
for i in range(4):
    if dice1.t == dice2.t and dice1.f == dice2.f and dice1.r == dice2.r and dice1.l == dice2.l and dice1.ba == dice2.ba and dice1.bo == dice2.bo:
        print("Yes")
        break
    dice2.N()
    dice2.E()
    dice2.S()
    if i == 3:
        print("No")

Submission status: Accepted

Solution code:
class Dice:
    def __init__(self):
        self.dice = [
                    [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, 5, 2, 3, 0, 4],
                    [1, 2, 0, 5, 3, 4],
                    [1, 0, 3, 2, 5, 4],
                    [1, 3, 5, 0, 2, 4],
                    [2, 1, 5, 0, 4, 3],
                    [2, 5, 4, 1, 0, 3],
                    [2, 4, 0, 5, 1, 3],
                    [2, 0, 1, 4, 5, 3],
                    [3, 1, 0, 5, 4, 2],
                    [3, 0, 4, 1, 5, 2],
                    [3, 4, 5, 0, 1, 2],
                    [3, 5, 1, 4, 0, 2],
                    [4, 0, 2, 3, 5, 1],
                    [4, 2, 5, 0, 3, 1],
                    [4, 5, 3, 2, 0, 1],
                    [4, 3, 0, 5, 2, 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]]

    def math(self, dice_p1, dice_p2):
        dice_t = []
        same = "No"
        for dice_p in self.dice:
            for i in range(6):
                dice_t.append(dice_p1[dice_p[i]])
            if dice_t == dice_p2:
                same = "Yes"
            dice_t = []
        return same

d = Dice()
dice_p1 = [int(dice_p1) for dice_p1 in input().split()]
dice_p2 = [int(dice_p2) for dice_p2 in input().split()]
print(d.math(dice_p1, dice_p2))

Submission status: Accepted

Solution code:
x = list(map(int, input().split()))
y = list(map(int, input().split()))
z = [[0, 1, 2, 0], [0, 2, 1, 1], [2, 1, 0, 1], [1, 0, 2, 1], [2, 0, 1, 0], [1, 2, 0, 0]]
for i in range(6):
    order = [0, 0, 0]
    for j in range(3):
        if x[j] == y[z[i][j]] and x[-j-1] == y[-z[i][j]-1]:
            pass
        elif x[j] == y[-z[i][j]-1] and x[-j-1] == y[z[i][j]]:
            order[j] = 1
            if x[j] == x[-j-1]:
                order[j] = 2
        else:
            break
    else:
        if 2 in order or z[i][3] == sum(order) % 2:
            print('Yes')
            break
else:
    print('No')

Submission status: Accepted

Solution code:
x = list(map(int, input().split()))
y = list(map(int, input().split()))
z = [0, 1, 2]
for i in range(6):
    order = [0, 0, 0]
    for j in range(3):
        if {x[j], x[-j-1]} != {y[z[j]], y[-z[j]-1]}:
            break
        if x[j] == y[z[j]]:
            order[j] = 1 
            if x[j] == x[-j-1]:
                order[j] = 2 
    else:
        if 2 in order or (i < 3) == sum(order) % 2:
            print('Yes')
            break
    z = z[-1:] + z[:-1]
    if i == 2:
        z = [z[0], z[2], z[1]]
else:
    print('No')

Submission status: Accepted

Solution code:
x = list(map(int, input().split()))
y = list(map(int, input().split()))
z = [0, 1, 2]
for i in range(6):
    order = [0, 0, 0]
    for j in range(3):
        if {x[j], x[-j-1]} != {y[z[j]], y[-z[j]-1]}:
            break
        if x[j] == y[z[j]]:
            order[j] = 1 
            if x[j] == x[-j-1]:
                order[j] = 2 
    else:
        if 2 in order or (i < 3) == sum(order) % 2:
            print('Yes')
            break
    z = [z[2], z[0], z[1]]
    if i == 2:
        z = [z[0], z[2], z[1]]
else:
    print('No')

Submission status: Accepted

Solution code:
x = input().split()
y = input().split()
z = [0, 1, 2]
for i in range(6):
    order = [0, 0, 0]
    for j in range(3):
        if {x[j], x[-j-1]} != {y[z[j]], y[-z[j]-1]}:
            break
        if x[j] == y[z[j]]:
            order[j] = 1 
            if x[j] == x[-j-1]:
                order[j] = 2 
    else:
        if 2 in order or (i < 3) == sum(order) % 2:
            print('Yes')
            break
    z = [z[2], z[0], z[1]]
    if i == 2:
        z = [z[0], z[2], z[1]]
else:
    print('No')

Submission status: Accepted

Solution code:
x = input().split()
y = input().split()
a = [0, 1, 2]
for i in range(6):
    order = [0, 0, 0]
    for j in range(3):
        k = a[j]
        if {x[j], x[-j-1]} != {y[k], y[-k-1]}:
            break
        if x[j] == y[k]:
            order[j] = 1
            if x[j] == x[-j-1]:
                order[j] = 2
    else:
        if 2 in order or (i < 3) == sum(order) % 2:
            print('Yes')
            break
    a = [a[2], a[0], a[1]]
    if i == 2:
        a = [a[0], a[2], a[1]]
else:
    print('No')

Submission status: Accepted

Solution code:
class Dice:
    same_dice_index = ('123456', '135246', '142536', '154326',
                       '214365', '231645', '246135', '263415',
                       '312564', '326154', '351624', '365214',
                       '415263', '421653', '456123', '462513',
                       '513462', '536142', '541632', '564312',
                       '624351', '632541', '645231', '653421')
 
    def __init__(self, num_list):
        self.faces = num_list
 
    def is_same(self, dice):
        for i in Dice.same_dice_index:
            example_faces = []
            for j in i:
                example_faces.append(self.faces[int(j) - 1])
            if example_faces == dice.faces:
                return 'Yes'
        return 'No'
 
num_list1 = list(map(int, input().split()))
num_list2 = list(map(int, input().split()))
 
dice1 = Dice(num_list1)
dice2 = Dice(num_list2)
 
ans = dice1.is_same(dice2)
 
print(ans)

Submission status: Accepted

Solution code:
import sys
x1=[int(i)for i in input().split()]
x2=[int(i)for i in input().split()]
for i in range(6):
    if x2[i]==x1[0]:
        count=i
        if x2[5-i]==x1[5]:
            break
if x2[count]==x1[0] and x2[5-count]==x1[5]:
    if count==0 or count==5:
        if count==5:
            for i in range(2):
                x2[1],x2[0]=x2[0],x2[1]
                x2[5],x2[1]=x2[1],x2[5]
                x2[4],x2[5]=x2[5],x2[4]
    else:
        if count==1 or count==4:
            while x1[0]!=x2[0] or x1[5]!=x2[5]:
                x2[1],x2[0]=x2[0],x2[1]
                x2[5],x2[1]=x2[1],x2[5]
                x2[4],x2[5]=x2[5],x2[4]
        else:
            while x1[0]!=x2[0] or x1[5]!=x2[5]:
                x2[3],x2[0]=x2[0],x2[3]
                x2[5],x2[3]=x2[3],x2[5]
                x2[2],x2[5]=x2[5],x2[2]
    for i in range(4):
        if x2[2]==x1[2] and x2[3]==x1[3] and x2[4]==x1[4] and x2[1]==x1[1] :
            print('Yes')
            break
        else:
            x2[1],x2[2]=x2[2],x2[1]
            x2[2],x2[4]=x2[4],x2[2]
            x2[4],x2[3]=x2[3],x2[4]
        if i==3:
            print('No')
else:
    print("No")

Submission status: Accepted

Solution code:
store=[]
str=["N","S","E","W"]
rep={
 "N":[4,0,2,3,5,1],
 "S":[1,5,2,3,0,4],
 "E":[2,1,5,0,4,3],
 "W":[3,1,0,5,4,2]}

def rotate_dice(b,s):
 result = [0]*6
 for i in range(6):result[i]=b[rep[s][i]]
 return result
     
def check(a,b):
 if not b in store:
  store.append(b)
  for s in str:
   check(a,rotate_dice(b,s))
 
a=input().split()
b=input().split()
r=check(a,b)
if a in store:
 print("Yes")
else:
 print("No")

Submission status: Accepted

Solution code:
store=[]
str=["N","S","E","W"]
rep={
 "N":[4,0,2,3,5,1],
 "S":[1,5,2,3,0,4],
 "E":[2,1,5,0,4,3],
 "W":[3,1,0,5,4,2]}
 
def rotate_dice(b,s):
 result = [0]*6
 for i in range(6):
  result[i]=b[rep[s][i]]
 return result
      
def check(a,b):
 if not b in store:
  store.append(b)
  for s in str:
   check(a,rotate_dice(b,s))
  
a=input().split()
b=input().split()
r=check(a,b)
if a in store:
 print("Yes")
else:
 print("No")

Submission status: Accepted

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
???????????? 3

?¬?????±??????????????????????????????????????????¢??????????????\??¬????????§????????????????????°????????????????????????????????????
   +--+
 ???|???|
+--+--+--+--+
|???|???|???|???|
+--+--+--+--+
 ???|???|
   +--+

"""

class Dice:
    T = 0
    S = 1
    E = 2
    W = 3
    N = 4
    B = 5

    """ ????????????????????? """
    def __init__(self): # ?????????????????????
        self.side = [1, 2, 3, 4, 5, 6]
        self.top = 0

    def setDice(self, arr):  # ??¢??????????????????
        self.side = arr[0:6]

    def Turn(self, dir): # ?????????????????¢??????
        s = self.side

        if dir == "N":     # ????????¢??????
            #    Top 0     South 1   East 2    West 3    North 4   Bottom 5
            t = [s[Dice.S],s[Dice.B],s[Dice.E],s[Dice.W],s[Dice.T],s[Dice.N]]
        elif dir == "S": # ????????¢??????
            t = [s[Dice.N],s[Dice.T],s[Dice.E],s[Dice.W],s[Dice.B],s[Dice.S]]
        elif dir == "E": # ??±?????¢??????
            t = [s[Dice.W],s[Dice.S],s[Dice.T],s[Dice.B],s[Dice.N],s[Dice.E]]
        elif dir == "W": # ?\??????¢??????
            t = [s[Dice.E],s[Dice.S],s[Dice.B],s[Dice.T],s[Dice.N],s[Dice.W]]
        elif dir == "L": # ???????????¢
            t = [s[Dice.T],s[Dice.W],s[Dice.S],s[Dice.N],s[Dice.E],s[Dice.B]]
        elif dir == "R": # ???????????¢
            t = [s[Dice.T],s[Dice.E],s[Dice.N],s[Dice.S],s[Dice.W],s[Dice.B]]

        self.side = t
#        print("{0} T0:{1} S1:{2} W2:{3} E3:{4} N4:{5} B5:{6} ".format(dir, self.side[0],self.side[1], self.side[2],self.side[3], self.side[4],self.side[5]))

    def Search(self, tval, sval, dir): # ?????¢??¨?????¢???????????????????????????????????¢???????????????
#        print("{0} T0:{1} S1:{2} W2:{3} E3:{4} N4:{5} B5:{6} ".format(dir, self.side[0],self.side[1], self.side[2],self.side[3], self.side[4],self.side[5]))
    
        if self.side[Dice.E] == tval:
            self.Turn("W")
        elif self.side[Dice.W] == tval:
            self.Turn("E")
        elif self.side[Dice.N] == tval:
            self.Turn("S")
        elif self.side[Dice.S] == tval:
            self.Turn("N")
        elif self.side[Dice.B] == tval:
            self.Turn("N")
            self.Turn("N")

        for i in range(3): # ?????¢?????????????????????????????§????????????
            if self.side[Dice.S] == sval:
                break
            self.Turn("L")
            
        return self.side[dir]

# ?????????
d1num = list(map(int,input().strip().split()))
d2num = list(map(int,input().strip().split()))
d1 = Dice()
d1.setDice(d1num)
d2 = Dice()
d2.setDice(d2num)
v1 = d1.Search(d1.side[Dice.T], d1.side[Dice.S], Dice.E)
v2 = d2.Search(d1.side[Dice.T], d1.side[Dice.S], Dice.E)
if v1 == v2:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
class dice:
	def __init__(self,data):
		self.faces = data
	
	def turn(self,direction):
		if direction == 'N':
			idx = [1,5,2,3,0,4]
			self.faces = [self.faces[i] for i in idx]
		elif direction == 'S':
			[self.turn('N') for i in range(3)]
		elif direction == 'E':
			idx = [3,1,0,5,4,2]
			self.faces = [self.faces[i] for i in idx]
		elif direction == 'W':
			[self.turn('E') for i in range(3)]
		elif direction == 'c':
			self.turn('N')
			self.turn('W')
			self.turn('S')

if __name__ == '__main__':
	data1 = [int(i) for i in input().split()]
	data2 = [int(i) for i in input().split()]
	d1 = dice(data1)
	d2 = dice(data2)
	
	for o in 'cccWcccEcccNcccWcccWccc':
		if d1.faces == d2.faces:
			break
		else:
			d2.turn(o)
	if d1.faces == d2.faces:
		print('Yes')
	else:
		print('No')