Problem:


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

Dice IV

 Write a program which reads $n$ dices constructed in the same way as Dice I, and determines whether they are all different. For the determination, use the same way as Dice III.

Input

  In the first line, the number of dices $n$ is given. In the following $n$ lines, six integers assigned to the dice faces are given respectively in the same way as Dice III.

Output

  Print "Yes" if given dices are all different, otherwise "No" in a line.

Constraints

$2 \leq n \leq 100$

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

Sample Input 1

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

Sample Output 1

No

Sample Input 2 

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

Sample Output 2

Yes



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


Sample output:
No

Submission status: Accepted

Solution code:

#0:上面　1:S 2:E 3:W 4:N 5:下
class Dice:
    def __init__(self):#クラス内で用いる変数の定義（クラス作成時に代入しなくてよい）
        self.number = [i for i in range(6)]
        self.work = [i for i in range(6)]
        self.order = 'NNNNWNNNWNNNENNNENNNWNNN'
    #サイコロの目の数を設定
    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):#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])
        else:
            self.setNumber(self.work[2],self.work[1],self.work[5],self.work[0],self.work[4],self.work[3])
    
    def equals(self, another):
        ret = False;
        
        for i in range(len(self.order)):
            self.roll(self.order[i])
            flag = True
            for k in range(6):
                if self.number[k] != another.number[k]:
                    flag = False
                    break
            if flag == True:
                return True
        
        return ret
          

n = int(input())
DICE = []#インスタンスのリスト

for i in range(n):
    table = list(map(int, input().split()))
    tmp = Dice()
    tmp.setNumber(table[0],table[1],table[2],table[3],table[4],table[5])#init
    DICE.append(tmp)

flag = True

for i in range(n-1):
    for k in range(i+1, n):
        if DICE[i].equals(DICE[k]) ==True:
            flag = False
            break

if flag:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
import enum
class Direction(enum.Enum):
    N = "N"
    E = "E"
    W = "W"
    S = "S"

    @classmethod
    def value_of(cls, value):
        return [v for v in cls if v.value == value][0]


class Dice:
    def __init__(self, *value_list):
        self.__value_list = list(value_list)

    def rotate(self, direction):
        l = self.__value_list
        if  direction == Direction.N:
            l[0],l[1],l[5],l[4] = l[1],l[5],l[4],l[0]
        elif  direction == Direction.E:
            l[0],l[2],l[5],l[3] = l[3],l[0],l[2],l[5]
        elif  direction == Direction.W:
            l[0],l[2],l[5],l[3] = l[2],l[5],l[3],l[0]
        elif  direction == Direction.S:
            l[0],l[1],l[5],l[4] = l[4],l[0],l[1],l[5]

    def adjust_top_front(self, top_value, front_value):
        for _ in range(2):
            for _ in range(3):
                if self.front_value() == front_value:
                    break
                self.rotate(Direction.N)
            if self.front_value() == front_value:
                break
            self.rotate(Direction.E)
        
        for _ in range(3):
            if self.top_value() == top_value:
                break
            self.rotate(Direction.E)
    
    def is_same_dice(self, othere_dice):
        return (self.top_value() == othere_dice.top_value()
        and self.bottom_value() == othere_dice.bottom_value()
        and self.front_value() == othere_dice.front_value()
        and self.behind_value() == othere_dice.behind_value()
        and self.right_value() == othere_dice.right_value()
        and self.left_value() == othere_dice.left_value())

    def top_value(self):
        return self.__value_list[0]

    def bottom_value(self):
        return self.__value_list[5]

    def front_value(self):
        return self.__value_list[1]

    def behind_value(self):
        return self.__value_list[4]

    def right_value(self):
        return self.__value_list[2]

    def left_value(self):
        return self.__value_list[3]


is_all_different = True
for i in range(int(input())):
    dice_x = Dice(*input().split())
    if i == 0:
        dice1 = dice_x
    else:
        dice_x.adjust_top_front(dice1.top_value(), dice1.front_value())
        if dice1.is_same_dice(dice_x):
            is_all_different = False
            break

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

Submission status: Accepted

Solution code:
class dice():
    top = 1
    flont = 2
    right = 3
    def do_N(self):
        temp = self.flont
        self.flont = 7-self.top
        self.top = temp

    def do_S(self):
        temp = 7-self.flont
        self.flont = self.top
        self.top = temp

    def do_E(self):
        temp = self.top
        self.top = 7-self.right
        self.right = temp

    def do_W(self):
        temp = 7-self.top
        self.top = self.right
        self.right = temp
        
        
n = int(input())
num = [[0]*6 for i in range(n)]
dice_list = []*n
flag = [0]*n

for i in range(n):
    num[i] = list(map(int, input().split()))
    dice_list.append(dice())    

for i in range(1, n):
    if num[0][dice_list[0].flont-1] == num[i][dice_list[i].flont-1] and num[0][dice_list[0].top-1] == num[i][dice_list[i].top-1] and num[0][dice_list[0].right-1] == num[i][dice_list[i].right-1] and num[0][7-dice_list[0].top-1] == num[i][7-dice_list[i].top-1] and num[0][7-dice_list[0].flont-1] == num[i][7-dice_list[i].flont-1] and num[0][7-dice_list[0].right-1] == num[i][7-dice_list[i].right-1]:
        flag[i] = 1
    for j in range(4):
        for k in range(4):
            dice_list[i].do_E()
            if num[0][dice_list[0].flont-1] == num[i][dice_list[i].flont-1] and num[0][dice_list[0].top-1] == num[i][dice_list[i].top-1] and num[0][dice_list[0].right-1] == num[i][dice_list[i].right-1] and num[0][7-dice_list[0].top-1] == num[i][7-dice_list[i].top-1] and num[0][7-dice_list[0].flont-1] == num[i][7-dice_list[i].flont-1] and num[0][7-dice_list[0].right-1] == num[i][7-dice_list[i].right-1]:
                flag[i] = 1
        dice_list[i].do_N()
        if num[0][dice_list[0].flont-1] == num[i][dice_list[i].flont-1] and num[0][dice_list[0].top-1] == num[i][dice_list[i].top-1] and num[0][dice_list[0].right-1] == num[i][dice_list[i].right-1] and num[0][7-dice_list[0].top-1] == num[i][7-dice_list[i].top-1] and num[0][7-dice_list[0].flont-1] == num[i][7-dice_list[i].flont-1] and num[0][7-dice_list[0].right-1] == num[i][7-dice_list[i].right-1]:
            flag[i] = 1    
    dice_list[i].do_S()
    dice_list[i].do_E()
    if num[0][dice_list[0].flont-1] == num[i][dice_list[i].flont-1] and num[0][dice_list[0].top-1] == num[i][dice_list[i].top-1] and num[0][dice_list[0].right-1] == num[i][dice_list[i].right-1] and num[0][7-dice_list[0].top-1] == num[i][7-dice_list[i].top-1] and num[0][7-dice_list[0].flont-1] == num[i][7-dice_list[i].flont-1] and num[0][7-dice_list[0].right-1] == num[i][7-dice_list[i].right-1]:
        flag[i] = 1
    for j in range(4):
        for k in range(4):
            dice_list[i].do_E()
            if num[0][dice_list[0].flont-1] == num[i][dice_list[i].flont-1] and num[0][dice_list[0].top-1] == num[i][dice_list[i].top-1] and num[0][dice_list[0].right-1] == num[i][dice_list[i].right-1] and num[0][7-dice_list[0].top-1] == num[i][7-dice_list[i].top-1] and num[0][7-dice_list[0].flont-1] == num[i][7-dice_list[i].flont-1] and num[0][7-dice_list[0].right-1] == num[i][7-dice_list[i].right-1]:
                flag[i] = 1
        dice_list[i].do_N()
        if num[0][dice_list[0].flont-1] == num[i][dice_list[i].flont-1] and num[0][dice_list[0].top-1] == num[i][dice_list[i].top-1] and num[0][dice_list[0].right-1] == num[i][dice_list[i].right-1] and num[0][7-dice_list[0].top-1] == num[i][7-dice_list[i].top-1] and num[0][7-dice_list[0].flont-1] == num[i][7-dice_list[i].flont-1] and num[0][7-dice_list[0].right-1] == num[i][7-dice_list[i].right-1]:
            flag[i] = 1

if max(flag) == 1:
    print("No")
else:
    print("Yes")

Submission status: Accepted

Solution code:
# ['表面', '南面', '東面', '西面', '北面', '裏面']
N = int(input())
dices = [[int(d) for d in input().split()] for _ in range(N)]

R1 = [
    [0, 1, 2, 3, 4, 5], # 移動なし
    [3, 1, 0, 5, 4, 2], # 東へ1
    [2, 1, 5, 0, 4, 3], # 西へ1
    [4, 0, 2, 3, 5, 1], # 南へ1
    [1, 5, 2, 3, 0, 4], # 北へ1
    [5, 4, 2, 3, 1, 0]  # 北へ2
]

R2 = [0, 3, 1, 4, 2, 5] # 水平回り1

ans = 'Yes'

for i in range(N):
    for j in range(i + 1, N):
        for r1 in R1:
            dice = [dices[j][k] for k in r1]
            for _ in range(4):
                dice = [dice[l] for l in R2]
                if dices[i] == dice:
                    ans = 'No'

print(ans)

Submission status: Accepted

Solution code:
class Dice:
    def __init__(self, num):
        self.num = num
    def roll(self, fn):
        if fn == "S":
            ue = self.num[4]
            self.num[4] = self.num[5]
            self.num[5] = self.num[1]
            self.num[1] = self.num[0]
            self.num[0] = ue
        elif fn == "W":
            ue = self.num[2]
            self.num[2] = self.num[5]
            self.num[5] = self.num[3]
            self.num[3] = self.num[0]
            self.num[0] = ue        
        elif fn == "N":
            ue = self.num[1]
            self.num[1] = self.num[5]
            self.num[5] = self.num[4]
            self.num[4] = self.num[0]
            self.num[0] = ue                
 
    def spin(self, fn):
        if fn == "migi":
            mae = self.num[3]
            self.num[3] = self.num[4]
            self.num[4] = self.num[2]
            self.num[2] = self.num[1]
            self.num[1] = mae

n = int(input())
dice = []
for i in range(n):
    num = list(map(int, input().split(" ")))
    dice.append(Dice(num))
for i in range(1, n):
    count = 0
    while dice[0].num[0] != dice[i].num[0] and count<5:
        dice[i].roll("S")
        count+=1
    count = 0
    while dice[0].num[0] != dice[i].num[0] and count<5:
        dice[i].roll("W")
        count+=1       
    count = 0
    while dice[0].num[1] != dice[i].num[1] and count<5:
        dice[i].spin("migi")
        count+= 1
count = 0
for i in range(0, len(dice)-1):
    for j in range(1, len(dice)):
        if dice[i].num == dice[j].num:
            count += 1
if count > n-2:
    print("No")
else:
    print("Yes")

Submission status: Accepted

Solution code:
def Roll(c, lst) :
    if c == 'N' :
        lst[0], lst[1], lst[5], lst[4] = lst[1], lst[5], lst[4], lst[0]
    elif c == 'S' :
        lst[0], lst[1], lst[5], lst[4] = lst[4], lst[0], lst[1], lst[5]
    elif c == 'E' :
        lst[0], lst[2], lst[5], lst[3] = lst[3], lst[0], lst[2], lst[5]
    elif c == 'W' :
        lst[0], lst[2], lst[5], lst[3] = lst[2], lst[5], lst[3], lst[0]
    return lst
    

def Comp_Dice(dice_A, dice_B) :
    for i in range(4) :
        if dice_B[1] == dice_A[1] :
            break
        else :
            Roll('S', dice_B)
    if dice_B[1] != dice_A[1] :
        Roll('E', dice_B)
        for i in range(4) :
            if dice_B[1] == dice_A[1] :
                break
            else :
                Roll('S', dice_B)
    for i in range(4) :
        if dice_B[0] == dice_A[0] :
            break
        else :
            Roll('E', dice_B)

    if dice_B[0] == dice_A[0] and dice_B[1] == dice_A[1] and dice_B[2] == dice_A[2] and dice_B[3] == dice_A[3] and dice_B[4] == dice_A[4] and dice_B[5] == dice_A[5] :
        return "Same"
    else :
        return "Different"
        
import copy
ans = "Yes"
N = int(input())
dice_X = list(map(int, input().split()))
for i in range(N-1) :
    dice_Y = list(map(int, input().split()))
    if Comp_Dice(dice_X, dice_Y) == "Same" :
        ans = "No"
        break

print(ans)

Submission status: Accepted

Solution code:
class Dice:
    def __init__(self, top: str, front: str, right: str, left: str, back: str, bottom: str) -> None:
        self.top = top
        self.front = front
        self.right = right
        self.left = left
        self.back = back
        self.bottom = bottom

    def __eq__(self, other) -> bool:
        for directions in ['', 'N', 'SE', 'WW', 'ES', 'S']:
            for direction in directions:
                other.roll(direction)

            for _ in range(4):
                other.rotate_right()
                if (
                        self.top == other.top
                        and self.front == other.front
                        and self.back == other.back
                        and self.right == other.right
                        and self.left == other.left
                        and self.bottom == other.bottom
                ):
                    return True
        return False

    def print_top(self):
        print(self.top)

    def print_right(self):
        print(self.right)

    def roll(self, direction: str) -> None:
        if direction == 'S':
            self.south()
        elif direction == 'N':
            self.north()
        elif direction == 'E':
            self.east()
        elif direction == 'W':
            self.west()

    def north(self):
        [self.top, self.back, self.bottom, self.front] = [self.front, self.top, self.back, self.bottom]

    def south(self):
        [self.top, self.back, self.bottom, self.front] = [self.back, self.bottom, self.front, self.top]

    def east(self):
        [self.top, self.right, self.bottom, self.left] = [self.left, self.top, self.right, self.bottom]

    def west(self):
        [self.top, self.right, self.bottom, self.left] = [self.right, self.bottom, self.left, self.top]

    def rotate_right(self) -> None:
        for direction in 'SWN':
            self.roll(direction)


n = int(input())
dices = []
for _ in range(n):
    dices.append(Dice(*input().split()))

dice1 = dices[0]
all_different = all(map(lambda dice: dice != dice1, dices[1:]))
if all_different:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
class Dice():
    def __init__(self, a, b, c, d, e, f):
        """面の数字とindexを一致させるために0を挿入"""
        self.s = [0, a, b, c, d, e, f]

    def rotate(self, dir):
        if dir == "N":
            self.s[0] = self.s[1] #s[0]に一時的にs[1]を保持
            self.s[1] = self.s[2] 
            self.s[2] = self.s[6]
            self.s[6] = self.s[5]
            self.s[5] = self.s[0]
            return

        elif dir == "W":
            self.s[0] = self.s[1]
            self.s[1] = self.s[3] 
            self.s[3] = self.s[6]
            self.s[6] = self.s[4]
            self.s[4] = self.s[0]
            return

        elif dir == "S":
            self.s[0] = self.s[1]
            self.s[1] = self.s[5] 
            self.s[5] = self.s[6]
            self.s[6] = self.s[2]
            self.s[2] = self.s[0]
            return

        elif dir == "E":
            self.s[0] = self.s[1]
            self.s[1] = self.s[4] 
            self.s[4] = self.s[6]
            self.s[6] = self.s[3]
            self.s[3] = self.s[0]
            return
        
        elif dir == "R":
            self.s[0] = self.s[2]
            self.s[2] = self.s[3] 
            self.s[3] = self.s[5]
            self.s[5] = self.s[4]
            self.s[4] = self.s[0]
            return

        else:
            return

    def equal(self, dice2):
        FLG = False
        if set(self.s[1:]) != set(dice2.s[1:]):
            pass 

        elif self.s[1:] != dice2.s[1:]:
            for _ in range(3):
                if self.s[1:] != dice2.s[1:]:
                    for __ in range(4):
                        if self.s[1:] != dice2.s[1:]:
                            dice2.rotate("R")
                        else:
                            FLG = True
                            break
                    if FLG:
                        break

                    dice2.rotate("S")
                    for __ in range(4):
                        if self.s[1:] != dice2.s[1:]:
                            dice2.rotate("R")
                        else:
                            FLG = True
                            break
                    if FLG:
                        break
                    dice2.rotate("E")
                else:
                    FLG = True 
                if FLG:
                    break
        else:
            FLG = True

        return FLG

n = int(input())
*dices, = [Dice(*map(int, input().split())) for _ in range(n)]
FLG = True

for i in range(n):
    for j in range(i+1, n):
        if dices[i].equal(dices[j]):
            FLG = False
            break
    if not FLG:
        break

if FLG:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
class Dice(object):
    def __init__(self, init_numbers: list):
        self.numbers = dict(zip(("T", "S", "E", "W", "N", "B"), init_numbers))

    def _roll(self, old_part: tuple):
        new_part = old_part[1:] + (old_part[0],)
        new_numbers = [self.numbers[face] for face in new_part]

        for old, new in zip(old_part, new_numbers):
            self.numbers[old] = new

    def vroll(self, reverse=False):
        """北方向に回転"""
        old_part = ("N", "T", "S", "B")
        self._roll(old_part if not reverse else old_part[::-1])

    def hroll(self, reverse=False):
        """時計回りに回転"""
        old_part = ("N", "W", "S", "E")
        self._roll(old_part if not reverse else old_part[::-1])

    def roll_to(self, direction: str):

        if direction == "N":
            self.vroll()
        elif direction == "S":
            self.vroll(reverse=True)
        elif direction == "E":
            self.hroll(reverse=True)
            self.vroll()
            self.hroll()
        elif direction == "W":
            self.hroll()
            self.vroll()
            self.hroll(reverse=True)
        else:
            raise AssertionError


def is_same(dice1: Dice, dice2: Dice):

    result = False

    for direction in ["N", "E"] * 3:
        dice1.roll_to(direction)
        for _ in range(4):
            result |= dice1.numbers == dice2.numbers
            dice1.hroll()

    return result


if __name__ == "__main__":
    from itertools import combinations

    n = int(input())
    dices = []
    for _ in range(n):
        dices.append(Dice(list(map(int, input().split()))))

    all_different = True
    for i, j in combinations(dices, r=2):
        all_different &= not is_same(i, j)

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

Submission status: Accepted

Solution code:
import copy


class Dice:
    def __init__(self, one: int, two: int, three: int, four: int, five: int, six: int) -> None:
        self.__one = one
        self.__two = two
        self.__three = three
        self.__four = four
        self.__five = five
        self.__six = six

    def roll(self, direction) -> None:
        if direction == "N":
            tmp = self.__one
            self.__one = self.__two
            self.__two = self.__six
            self.__six = self.__five
            self.__five = tmp

        if direction == "E":
            tmp = self.__one
            self.__one = self.__four
            self.__four = self.__six
            self.__six = self.__three
            self.__three = tmp

        if direction == "S":
            tmp = self.__one
            self.__one = self.__five
            self.__five = self.__six
            self.__six = self.__two
            self.__two = tmp

        if direction == "W":
            tmp = self.__one
            self.__one = self.__three
            self.__three = self.__six
            self.__six = self.__four
            self.__four = tmp

        if direction == "I":
            tmp = self.__one
            self.__one, self.__six = self.__six, self.__one
            self.__two, self.__five = self.__five, self.__two

    def set_top(self, top: int) -> bool:
        if self.__one != top:
            for i in range(3):
                self.roll("N")
                if (self.__one == top):
                    break
        if self.__one != top:
            for i in range(3):
                self.roll("E")
                if (self.__one == top):
                    break
        return self.__one == top

    def rotate(self) -> None:
        tmp = self.__two
        self.__two = self.__four
        self.__four = self.__five
        self.__five = self.__three
        self.__three = tmp

    def check(self, dice) -> bool:
        flag = True
        if self.__one != dice.__one:
            flag = False
        if self.__two != dice.__two:
            flag = False
        if self.__three != dice.__three:
            flag = False
        if self.__four != dice.__four:
            flag = False
        if self.__five != dice.__five:
            flag = False
        if self.__six != dice.__six:
            flag = False
        return flag

    @property
    def top(self) -> int:
        return self.__one

    @property
    def front(self) -> int:
        return self.__two

    @property
    def right(self) -> int:
        return self.__three

    @property
    def left(self) -> int:
        return self.__four

    @property
    def back(self) -> int:
        return self.__five

    @property
    def bottom(self) -> int:
        return self.__six


if __name__ == "__main__":
    n = int(input())
    dice_list = []
    for i in range(n):
        dice_item = list(map(int, input().split(' ')))
        dice_list.append(dice_item)

    for i in range(n-1):
        dice1_one, dice1_two, dice1_three, dice1_four, dice1_five, dice1_six = dice_list[i]
        for j in range(i+1, n):
            dice2_one, dice2_two, dice2_three, dice2_four, dice2_five, dice2_six = dice_list[
                j]

            dice1 = Dice(dice1_one, dice1_two, dice1_three,
                         dice1_four, dice1_five, dice1_six)
            dice2 = Dice(dice2_one, dice2_two, dice2_three,
                         dice2_four, dice2_five, dice2_six)

            directions = ["N", "E", "S", "W", "I"]
            for direction in directions:
                dice = copy.deepcopy(dice1)
                if not (dice1.top == dice2.top and dice1.bottom == dice2.bottom):
                    dice.roll(direction)
                if dice.top == dice2.top and dice.bottom == dice2.bottom:
                    if dice.front != dice2.front:
                        for k in range(3):
                            dice.rotate()
                            if dice.check(dice2):
                                print("No")
                                exit()
                    else:
                        if dice.check(dice2):
                            print("No")
                            exit()
    print("Yes")

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
Spyderエディタ

これは一時的なスクリプトファイルです
"""

class Dice():
    
    #      e[4]
    # e[3] e[0] e[2] e[5]
    #      e[1]

    #      m[4]
    # m[3] m[0] m[2]
    #      m[1]
    #      m[5]
    
    def __init__(self, nums):
        self.pos = nums
    
    def rot_E(self):
        e = self.pos
        self.pos = [e[3], e[1], e[0], e[5], e[4], e[2]]

    def rot_W(self):
        e = self.pos
        self.pos = [e[2], e[1], e[5], e[0], e[4], e[3]]

    def rot_S(self):
        e = self.pos
        self.pos = [e[4], e[0], e[2], e[3], e[5], e[1]]

    def rot_N(self):
        e = self.pos
        self.pos = [e[1], e[5], e[2], e[3], e[0], e[4]]
        
    def rot_CW(self):
        e = self.pos
        self.pos = [e[0], e[2], e[4], e[1], e[3], e[5]]

    def rot_CCW(self):
        e = self.pos
        self.pos = [e[0], e[3], e[1], e[4], e[2], e[5]]

    def rot_180(self):
        self.rot_CW()
        self.rot_N()
        self.rot_W()

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

    def face(self):
        return self.pos[1]

    def right(self, tf=None):
        # tf = (t,f) : 上面 / 正面のラベル

        if tf == None:
            print(self.pos[2])
            return

        t = self.pos.index(tf[0])  # 上面（の扱いになっている）のラベルを取得
        f = self.pos.index(tf[1])  # 前面（の扱いになっている）のラベルを取得
        
        # u,f,r
        dr = [(1,2,4,3),(0,3,5,2),(0,1,5,4),(0,4,5,1),(0,2,5,3),(1,3,4,2)]
        r = (dr[t].index(f) + 1) % 4
        print(self.pos[dr[t][r]])
        return

    def left(self):
        print(self.pos[3])
        return

    def back(self):
        print(self.pos[4])
        return

    def bottom(self):
        print(self.pos[5])
        return

    def fit_top(self,x):
        if x == 0:
            self.rot_S()
            self.rot_S()
        if x == 1:
            self.rot_N()
        if x == 3:
            self.rot_axis()
            self.rot_axis()
        if x == 4:
            self.rot_S()
        if x == 5:
            self.rot_axis()
            self.rot_axis()
            self.rot_axis()

    def check(self, d):
        f = False
        # 上面からスタート
        
        def rotate4():
            nonlocal f
            for _ in range(4):
                if self.pos == d.pos:
                    f = True
                self.rot_CW()

        rotate4()
        
        d.rot_N()
        rotate4()
        d.rot_S()
        
        d.rot_W()
        rotate4()
        d.rot_E()
        
        d.rot_S()
        rotate4()
        d.rot_N()
        
        d.rot_E()
        rotate4()
        d.rot_W()
        
        d.rot_S()
        d.rot_S()
        rotate4()
        
        return f
    
    
    def position(self, x):
        return self.pos.index(x)
    
# 各方向を総当りでチェックする

# d1 = Dice([int(x) for x in input().split()])
# d2 = Dice([int(x) for x in input().split()])

def main():

    f = False

    n = int(input())
    
    ds = []
    for i in range(n):
        dt = Dice([int(x) for x in input().split()])
        ds.append(dt)
    
        for j in range(i):
            if dt.check(ds[j]):
                f = True

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

def main2():
    d1 = Dice([6, 2, 4, 3, 5, 1])
    d2 = Dice([6, 5, 4, 3, 2, 1])    
    d3 = Dice([1,2,3,4,5,6])
    print(d1.check(d2))
    print(d1.check(d3))
    print(d2.check(d3))
    
main()

Submission status: Accepted

Solution code:
class dice():
    def __init__(self,labels):
        self.l=labels
    def check(self,d2):
        l1=self.l
        for a in range(4):
            l1[1],l1[2],l1[3],l1[4]=l1[2],l1[4],l1[1],l1[3]
            for b in range(4):
                l1[0],l1[3],l1[2],l1[5]=l1[2],l1[0],l1[5],l1[3]
                for c in range(4):
                    l1[0],l1[1],l1[5],l1[4]=l1[4],l1[0],l1[1],l1[5]
                    if l1==d2.l:
                        return True
                        break
"""
a=dice([int(i) for i in input().split()])
b=dice([int(i) for i in input().split()])
print("Yes" if a.check(b) else "No")

"""
l=[]
n=int(input())
for _ in range(n):
    l.append(dice([int(i) for i in input().split()]))
han=False
for x in range(n-1):
    for i in range(x+1,n):
        if l[x].check(l[i]):
            han=True
            break
print("No" if han else "Yes")

Submission status: Accepted

Solution code:
class Dice:
    def __init__(self, lst):
        self.a = lst[0]
        self.b = lst[1]
        self.c = lst[2]
        self.d = lst[3]
        self.e = lst[4]
        self.f = lst[5]
        
    def roll(self, orders):
        for order in orders:
            if order=='W':
                tmp = self.a
                self.a = self.c
                self.c = self.f
                self.f = self.d
                self.d = tmp
            elif order=='E':
                tmp = self.a
                self.a = self.d
                self.d = self.f
                self.f = self.c
                self.c = tmp
            elif order=='S':
                tmp = self.a
                self.a = self.e
                self.e = self.f
                self.f = self.b
                self.b = tmp
            elif order=='N':
                tmp = self.a
                self.a = self.b
                self.b = self.f
                self.f = self.e
                self.e = tmp
#             print(self.a, self.b, self.c, self.d, self.e, self.f)
#         print(self.a)
    
    def equal(self, dice_):
        if (self.a==dice_.a and
            self.b==dice_.b and
            self.c==dice_.c and
            self.d==dice_.d and
            self.e==dice_.e and
            self.f==dice_.f
           ):
            return True
        else:
            return False
       
            
import random
import itertools
if __name__ == '__main__':
    n = int(input())
    lsts = [[int(x) for x in input().split()] for _ in range(n)]
    ans = 'Yes'
    for lst in itertools.combinations(lsts, 2):
        dice1 = Dice(lst[0])
        dice2 = Dice(lst[1])
        for direction in 'EEENEEENEEESEEESEEENEEEN':
            if dice1.equal(dice2):
                ans='No'
                break
            else:
                dice1.roll(direction)
    print(ans)