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:
import itertools


class Dice:
    def __init__(self, a, b, c, d, e, f):
        # サイコロの現在一番上にある面
        self.a = a
        self.b = b
        self.c = c
        self.d = d
        self.e = e
        self.f = f

        # 他のダイスと一致したかどうか
        self.result = 0

    def move(self, move_str):
        for i in move_str:
            if i == "N":
                self.move_N()
            elif i == "E":
                self.move_E()
            elif i == "W":
                self.move_W()
            elif i == "S":
                self.move_S()

    def move_N(self):
        tmp1 = self.a
        tmp2 = self.e
        self.a = self.b
        self.b = self.f
        self.e = tmp1
        self.f = tmp2

    def move_E(self):
        tmp1 = self.a
        tmp2 = self.c
        self.a = self.d
        self.c = tmp1
        self.d = self.f
        self.f = tmp2

    def move_W(self):
        tmp1 = self.a
        tmp2 = self.d
        self.a = self.c
        self.c = self.f
        self.d = tmp1
        self.f = tmp2

    def move_S(self):
        tmp1 = self.a
        tmp2 = self.b
        self.a = self.e
        self.b = tmp1
        self.e = self.f
        self.f = tmp2

    def check_one_around(self, dice):
        """チェックのために時計回りに一周させる"""
        for _ in range(4):
            """時計回りに回転"""
            tmp1 = self.b
            tmp2 = self.d
            self.b = self.c
            self.c = self.e
            self.d = tmp1
            self.e = tmp2

            # ダイスが一致しているかチェック
            self.check_dice_same(dice)

    def check_dice_same(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
        ):
            self.result += 1

    def all_check(self, dice):
        self.clear_result()

        self.check_one_around(dice)
        # b面をトップにする
        self.move("N")
        self.check_one_around(dice)

        # c面をトップにする
        self.move("W")
        self.check_one_around(dice)

        # e面をトップにする
        self.move("W")
        self.check_one_around(dice)

        # d面をトップにする
        self.move("W")
        self.check_one_around(dice)

        # f面をトップにする
        self.move("N")
        self.check_one_around(dice)

    def clear_result(self):
        self.result = 0

n = int(input())

li = []
for _ in range(n):
    a, b, c, d, e, f = map(int, input().split())
    dice = Dice(a, b, c, d, e, f)
    li.append(dice)

# 順列走査
flg = True
for v in itertools.combinations(li, 2):
    v[0].all_check(v[1])
    if v[0].result != 0:
        flg = False
        break

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

Submission status: Accepted

Solution code:
class Dice():
    #0:上面、1:前面、2:側面(見える方)、3:側面(裏側)、4:背面、5:底面
    def __init__(self,numlist):
        self.lst=numlist
    
    def roll(self,direction):
        for x in direction:
            if x=="S" : self.lst=[self.lst[4],self.lst[0],self.lst[2],self.lst[3],self.lst[5],self.lst[1]]
            elif x=="N" : self.lst=[self.lst[1],self.lst[5],self.lst[2],self.lst[3],self.lst[0],self.lst[4]]
            elif x=="W" : self.lst=[self.lst[2],self.lst[1],self.lst[5],self.lst[0],self.lst[4],self.lst[3]]
            elif x=="E" : self.lst=[self.lst[3],self.lst[1],self.lst[0],self.lst[5],self.lst[4],self.lst[2]]        
    
    def dice_set_make(self):
        self.dice_set=[]
        for x in ["","W","WW","WWW","SE","SW"]:
            self.work=Dice(self.lst[:])
            self.work.roll(x)
            self.dice_set.append(self.work.lst)
            for _ in range(3):
                self.work.roll("S")
                self.dice_set.append(self.work.lst)
        
n=int(input())
dices_set=[]
for _ in range(n): 
    lst=list(map(int,input().split()))
    d1=Dice(lst)
    d1.dice_set_make()
    dices_set.append(sorted(d1.dice_set))

for x in dices_set:
    if dices_set.count(x)>=2 :
        print("No")
        break
else : print("Yes")

Submission status: Accepted

Solution code:
class Dice:
    D = {'E': (3, 1, 0, 5, 4, 2),
         'W': (2, 1, 5, 0, 4, 3),
         'S': (4, 0, 2, 3, 5, 1),
         'N': (1, 5, 2, 3, 0, 4)}
    def __init__(self, a, b, c, d, e, f):
        self.nbrs = [a, b, c, d, e, f]
    def rll(self, dr):
        self.nbrs = [self.nbrs[i] for i in self.D[dr]]
    def issame(self, othrdice):
        for i in 'NNNN':
            self.rll(i)
            for j in 'EEEE':
                self.rll(j)
                for k in 'NNNN':
                    self.rll(k)
                    if self.nbrs == othrdice.nbrs:
                        return True
        return False


n = int(input())
dices = []
for _ in range(n):
    a, b, c, d, e, f = input().split()
    dice = Dice(a, b, c, d, e, f)
    dices.append(dice)
for x in range(n - 1):
    for y in range(x + 1, n):
        if dices[y].issame(dices[x]):
            print('No')
            exit()
print('Yes')

Submission status: Accepted

Solution code:
class Dice():
    def __init__(self, spots):
        self.spots = [spots[i] for i in range(6)]
    
    def roll(self, direction):
        if direction == 0:
            self.spots = [self.spots[i] for i in [1, 5, 2, 3, 0, 4]]
        elif direction == 1:
            self.spots = [self.spots[i] for i in [3, 1, 0, 5, 4, 2]]
        elif direction == 2:
            self.spots = [self.spots[i] for i in [4, 0, 2, 3, 5, 1]]
        elif direction == 3:
            self.spots = [self.spots[i] for i in [2, 1, 5, 0, 4, 3]]
 

n = int(input())
my_dice = Dice(list(map(int, input().split())))

for _ in range(n - 1):
    my_target = list(map(int, input().split()))

    a, b = my_target[0], my_target[1]

    if b == my_dice.spots[0]:
        my_dice.roll(2)
    elif b == my_dice.spots[1]:
        pass
    elif b == my_dice.spots[2]:
        my_dice.roll(3)
        my_dice.roll(2)
    elif b == my_dice.spots[3]:
        my_dice.roll(1)
        my_dice.roll(2)
    elif b == my_dice.spots[4]:
        my_dice.roll(2)
        my_dice.roll(2)
    elif b == my_dice.spots[5]:
        my_dice.roll(0)

    if a == my_dice.spots[0]:
        pass
    elif a == my_dice.spots[2]:
        my_dice.roll(3)
    elif a == my_dice.spots[3]:
        my_dice.roll(1)
    elif a == my_dice.spots[5]:
        my_dice.roll(1)
        my_dice.roll(1)

    if my_dice.spots == my_target:
        print('No')
        break

else:
    print('Yes')

Submission status: Accepted

Solution code:
di = [list(input().split(' ')) for _ in range(int(input()))]
a = list('NNNNWNNNWNNNENNNENNNWNNN')
y = 0
for n in range(len(di)):
    for j in di[n+1:]:
        dice = j
        x = 0
        aa,bb,cc,dd,ee,ff  = di[n]
        for i in a:
            if i == 'W':
                dice = [dice[2],dice[1],dice[5],dice[0],dice[4],dice[3]]
            elif i == 'S':
                dice = [dice[4],dice[0],dice[2],dice[3],dice[5],dice[1]]
            elif i == 'N':
                dice = [dice[1],dice[5],dice[2],dice[3],dice[0],dice[4]]
            elif i == 'E':
                dice = [dice[3],dice[1],dice[0],dice[5],dice[4],dice[2]]
            if dice[0] == aa and dice[1] == bb and dice[2] == cc and dice[3] == dd and dice[4] == ee and dice[5] == ff:
                x = x + 1
        y = y + 1 if x > 0 else y
kome = 'No' if y > 0 else 'Yes'
print(kome)

Submission status: Accepted

Solution code:
class Dice:
    def __init__(self, top, south, east, west, north, bottom):
        self.top = top
        self.south = south
        self.east = east
        self.west = west
        self.north = north
        self.bottom = bottom

    def toN(self):
        tmp = self.top
        self.top = self.south
        self.south = self.bottom
        self.bottom = self.north
        self.north = tmp

    def toE(self):
        tmp = self.top
        self.top = self.west
        self.west = self.bottom
        self.bottom = self.east
        self.east = tmp

    def toS(self):
        tmp = self.top
        self.top = self.north
        self.north = self.bottom
        self.bottom = self.south
        self.south = tmp

    def toW(self):
        tmp = self.top
        self.top = self.east
        self.east = self.bottom
        self.bottom = self.west
        self.west = tmp

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

    def printWest(self):
        print(self.west)

    def printEast(self):
        print(self.east)

    def getTop(self, target):
        if self.top == target:
            return
        for i in range(3):
            self.toN()
            if self.top == target:
                return
        for i in range(3):
            self.toE()
            if self.top == target:
                return

        if self.top != target:
            print("Error")

    def getSouth(self, target):
        if self.south == target:
            return
        for i in range(3):
            self.lotate()
            if self.south == target:
                return
    
    def lotate(self):
        tmp = self.north
        self.north = self.east
        self.east = self.south
        self.south = self.west
        self.west = tmp

    def isSame(self, other):
        if self.top == other.top and \
           self.north == other.north and \
           self.east == other.east and \
           self.south == other.south and \
           self.west == other.west and \
           self.bottom == other.bottom:
            return True
        else:
            return False

    def compare(self, other):
        for i in range(4):
            for j in range(4):
                if self.isSame(other) == True:
                    return True
                self.lotate()
            self.toN()

        for i in range(4):
            for j in range(4):
                if self.isSame(other) == True:
                    return True
                self.lotate()
            self.toE()
        return False

n = int(input())
dice = []
for i in range(n):
    buf = input().split()
    a = int(buf[0])
    b = int(buf[1])
    c = int(buf[2])
    d = int(buf[3])
    e = int(buf[4])
    f = int(buf[5])
    dice.append(Dice(a, b, c, d, e, f))

same = False
for i in range(n-1):
    for j in range(i+1, n):
        if dice[i].compare(dice[j]) == True:
            print("No")
            same = True
            break
    if same == True:
        break

if same == False:
    print("Yes")

Submission status: Accepted

Solution code:
class Dice:
    def __init__(self, ary): # [top, front, right, left, back, bottom]
        self.__top = ary[0]
        self.__fro = ary[1]
        self.__rit = ary[2]
        self.__lft = ary[3]
        self.__bak = ary[4]
        self.__btm = ary[5]

    def turn_e(self): # 右に転がる
        self.__top, self.__lft, self.__btm, self.__rit = \
        self.__lft, self.__btm, self.__rit, self.__top

    def turn_s(self): # 手前に転がる
        self.__top, self.__fro, self.__btm, self.__bak = \
        self.__bak, self.__top, self.__fro, self.__btm

    def turn_w(self): # 左に転がる
        self.__top, self.__lft, self.__btm, self.__rit = \
        self.__rit, self.__top, self.__lft, self.__btm

    def turn_n(self): # 奥に転がる
        self.__top, self.__fro, self.__btm, self.__bak = \
        self.__fro, self.__btm, self.__bak, self.__top

    def spin_r(self): # 右回転 
        self.__rit, self.__fro, self.__lft, self.__bak = \
        self.__bak, self.__rit, self.__fro, self.__lft

    def spin_l(self): # 左回転
        self.__rit, self.__fro, self.__lft, self.__bak = \
        self.__fro, self.__lft, self.__bak, self.__rit

    def is_same_setting(self, ary): # 同じように置いているか
        if self.__top == ary[0] and self.__fro == ary[1] and self.__rit == ary[2] and \
            self.__lft == ary[3] and self.__bak == ary[4] and self.__btm == ary[5]:
            return True

    def is_same_dice(self, ary): # 回転させて同じダイスになるか
        is_same = False
        for _ in range(2):
            for _ in range(3):
                for _ in range(4):
                    if self.is_same_setting(ary):
                        is_same = True
                    self.spin_r()
                self.turn_n()
            self.spin_r()
            self.turn_s()
        return is_same

    def show_top(self): # 上面の値を表示
        return self.__top


n = int(input())
surfaces_stack = [None] * n
for i in range(n):
    surfaces_stack[i] = list(map(int,input().split()))

for i in range(n-1):
    for j in range(i+1, n):
        dice = Dice(surfaces_stack[i])
        if dice.is_same_dice(surfaces_stack[j]):
            print('No')
            break
    else:
        continue
    break
else:
    print('Yes')

Submission status: Accepted

Solution code:
import sys
reverse = {
    "E":"W",
    "W":"E",
    "S":"N",
    "N":"S"
    }
        
class dice:
    def __init__(self,A):
        self.list = sorted(A)
        self.max = max(A)
        self.min = min(A)
        self.side = {
            "TOP":A[0],
            "S":A[1],
            "E":A[2],
            "W":A[3],
            "N":A[4],
            "BOT":A[5],
            }
    def get_list(self):
        return self.list
    def get_dict(self):
        return self.side
    def check(self):
        pass
    def main(self,A):
        for s in A:
            var = int(self.side[s])
            self.side[s] = self.side["TOP"]
            self.side["TOP"] = self.side[reverse[s]]
            self.side[reverse[s]] = self.side["BOT"]
            self.side["BOT"] = var
    def rot(self):
        var = self.side["N"]
        self.side["N"] = self.side["E"]
        self.side["E"] = self.side["S"]
        self.side["S"] = self.side["W"]
        self.side["W"] = var
n = int(input())
data = [list(map(int,input().split())) for _ in range(n)]


for i in range(0,n-1):
    a = dice(data[i])
    a_dict = a.get_dict()
    for j in range(i+1,n):
        b = dice(data[j])
        for do in ["N","N","N","N","E","EE"]:
            b.main(do)
            for _ in range(4):
                b.rot()
                b_dict = b.get_dict()
                if a_dict == b_dict:
                    print("No")
                    exit()

        
print("Yes")

Submission status: Accepted

Solution code:
patterns = [
    [1, 2, 3, 4, 5, 6],
    [1, 3, 5, 2, 4, 6],
    [1, 5, 4, 3, 2, 6],
    [1, 4, 2, 5, 3, 6],
    [2, 6, 3, 4, 1, 5],
    [2, 3, 1, 6, 4, 5],
    [2, 1, 4, 3, 6, 5],
    [2, 4, 6, 1, 3, 5],
    [3, 6, 5, 2, 1, 4],
    [3, 5, 1, 6, 2, 4],
    [3, 1, 2, 5, 6, 4],
    [3, 2, 6, 1, 5, 4],
    [4, 6, 2, 5, 1, 3],
    [4, 2, 1, 6, 5, 3],
    [4, 1, 5, 2, 6, 3],
    [4, 5, 6, 1, 2, 3],
    [5, 3, 6, 1, 4, 2],
    [5, 6, 4, 3, 1, 2],
    [5, 4, 1, 6, 3, 2],
    [5, 1, 3, 4, 6, 2],
    [6, 2, 4, 3, 5, 1],
    [6, 3, 2, 5, 4, 1],
    [6, 4, 5, 2, 3, 1], 
    [6, 5, 3, 4, 2, 1]
]


n = int(input())
dices = []

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

p = []

for dice in dices:
    d = dict(zip(range(1,7), dice))
    s =[] 
    for pattern in patterns:
        c = [d.get(x) for x in pattern]
        c = tuple(c)
        s.append(c)
    s = tuple(s)
    p.append(s)

for i in range(len(p)):
    p2 = p[i][0]
    for j in range(i+1, len(p)):
        if p2 in p[j]:
            print('No')
            exit()

print('Yes')

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline


class Dice:
    """
    0:top, 1:south, 2:east, 3:west, 4:north, 5:bottom
    """

    def __init__(self, surfaces):
        self.init_surface = surfaces
        self.surface = surfaces

    def init_dice(self):
        self.surface = self.init_surface

    def roll(self, direction: str):
        if direction == "E":
            self.surface = [self.surface[3], self.surface[1], self.surface[0],
                            self.surface[5], self.surface[4], self.surface[2]]

        elif direction == "N":
            self.surface = [self.surface[1], self.surface[5], self.surface[2],
                            self.surface[3], self.surface[0], self.surface[4]]

        elif direction == "S":
            self.surface = [self.surface[4], self.surface[0], self.surface[2],
                            self.surface[3], self.surface[5], self.surface[1]]

        elif direction == "W":
            self.surface = [self.surface[2], self.surface[1], self.surface[5],
                            self.surface[0], self.surface[4], self.surface[3]]

        return

    def spin(self):
        self.surface = [self.surface[0], self.surface[3], self.surface[1],
                        self.surface[4], self.surface[2], self.surface[5]]
        return

    def get_surface(self, num):
        if num in self.surface:
            indexes = [i for i, x in enumerate(self.surface) if x == num]
            return indexes
        else:
            return []

    def get_top(self):
        return self.surface[0]

    def get_south(self):
        return self.surface[1]

    def get_east(self):
        return self.surface[2]


def is_same_dice(dice1: Dice, dice2: Dice):
    top1 = dice1.get_top()
    indexes = dice2.get_surface(top1)
    for cur in indexes:
        dice2.init_dice()
        if cur == 0:
            pass
        elif cur == 1:
            dice2.roll("N")
        elif cur == 2:
            dice2.roll("W")
        elif cur == 3:
            dice2.roll("E")
        elif cur == 4:
            dice2.roll("S")
        elif cur == 5:
            dice2.roll("S")
            dice2.roll("S")
        for _ in range(4):
            dice2.spin()
            if dice1.surface == dice2.surface:
                return True
    return False


def main():
    n = int(input())
    dices = list()
    for _ in range(n):
        surface = [int(i) for i in input().strip().split()]
        dices.append(Dice(surface))

    for i in range(n-1):
        for j in range(i + 1, n):
            if is_same_dice(dices[i], dices[j]):
                print("No")
                return

    print("Yes")
    return


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
class Dice(object):
    def __init__(self):
        self.number = [0 for _ in range(6)]
        self.before = [0 for _ in range(6)]
        self.init = [0 for _ in range(6)]

    def set_number(self, l):
        for i in range(6):
            self.number[i] = l[i]

    def roll(self, loc):
        d = {
            'N': (1, 5, 2, 3, 0, 4),
            'S': (4, 0, 2, 3, 5, 1),
            'E': (3, 1, 0, 5, 4, 2),
            'W': (2, 1, 5, 0, 4, 3)
        }
        for i in range(6):
            self.before[i] = self.number[i]

        for i, j in enumerate(d[loc]):
            self.number[i] = self.before[j]

    def roll_clockwise(self):
        for i in range(6):
            self.before[i] = self.number[i]
        self.number = [self.before[i] for i in (0, 2, 4, 1, 3, 5)]

    def set_Top_and_Front(self, top, front):
        top_index = self.number.index(top)
        if top_index == 5:
            self.roll('E')
            self.roll('E')
        elif top_index == 4:
            self.roll('S')
        elif top_index == 3:
            self.roll('E')
        elif top_index == 2:
            self.roll('W')
        elif top_index == 1:
            self.roll('N')
        front_index = self.number.index(front)
        if front_index == 1:
            pass
        elif front_index == 2:
            self.roll_clockwise()
        elif front_index == 3:
            self.roll_clockwise()
            self.roll_clockwise()
            self.roll_clockwise()
        elif front_index == 4:
            self.roll_clockwise()
            self.roll_clockwise()

    def set_Top(self, idx):
        if idx == 5:
            self.roll('E')
            self.roll('E')
        elif idx == 4:
            self.roll('S')
        elif idx == 3:
            self.roll('E')
        elif idx == 2:
            self.roll('W')
        elif idx == 1:
            self.roll('N')
        elif idx == 0:
            pass

    def check_identity(self, another_dice):
        res = False

        for i in range(6):
            self.init[i] = self.number[i]

        for i in range(6):
            self.set_Top(i)
            for j in range(4):
                if j == 0:
                    pass
                else:
                    self.roll_clockwise()
                if self.number == another_dice:
                    res = True
                    break
            if res:
                break
            for i in range(6):
                self.number[i] = self.init[i]
        return res


if __name__ == '__main__':
    n = int(input())
    l = [[int(i) for i in input().split()] for j in range(n)]
    res = False
    for i in range(len(l) - 1):
        d = Dice()
        d.set_number(l[i])
        for j in range(i + 1, len(l)):
            res = d.check_identity(l[j])
            if res:
                break
        if res:
            break
    print('No' if res else 'Yes')

Submission status: Accepted

Solution code:
class Dice():
    def __init__(self):
        self.num = [0 for _ in range(6)]
    
    def set_num(self, n0, n1, n2, n3, n4, n5):
        self.num[0] = n0
        self.num[1] = n1
        self.num[2] = n2
        self.num[3] = n3
        self.num[4] = n4
        self.num[5] = n5
    
    
    def roll(self, order):
        tmp = self.num.copy()
        
        if order == "N":
            self.set_num(tmp[1], tmp[5], tmp[2], tmp[3], tmp[0], tmp[4])
        elif order == "S":
            self.set_num(tmp[4], tmp[0], tmp[2], tmp[3], tmp[5], tmp[1])
        elif order == "E":
            self.set_num(tmp[3], tmp[1], tmp[0], tmp[5], tmp[4], tmp[2])
        elif order == "W":
            self.set_num(tmp[2], tmp[1], tmp[5], tmp[0], tmp[4], tmp[3])
        elif order == "rot_Clock":
            self.set_num(tmp[0], tmp[2], tmp[4], tmp[1], tmp[3], tmp[5])
        else:
            print("Error: 不正な入力です")

    def get_top_num(self):
        return self.num[0]
        

    
# Input
n_dice = int(input())
list_dice_num = []
for _ in range(n_dice):
    list_dice_num.append([int(_) for _ in input().split()])

# Set Dice
list_dice = []
for init_num1 in list_dice_num:
    dice1 = Dice()
    dice1.set_num(init_num1[0], init_num1[1], init_num1[2], init_num1[3], init_num1[4], init_num1[5])
    list_dice.append(dice1)

# 1st way
def check_dice_equal_1(dice1, dice2):
    checker = False
    for i in range(3):
        for j in range(3):
            orders = "N" * (i + 1) + "E" * (j + 1)
            # print(orders)
            
            for order in orders:
                dice2.roll(order)
            if dice1.num == dice2.num:
                checker = True
            
    for i in range(3):
        for j in range(3):
            orders = "E" * (i + 1) + "N" * (j + 1)
            # print(orders)
            
            for order in orders:
                dice2.roll(order)
            if dice1.num == dice2.num:
                checker = True
    
    for i in range(3):
        for j in range(3):
            for k in range(3):
                orders = "E" * (i + 1) + "N" * (j + 1) + "E" * (k + 1)
                # print(orders)
                
                for order in orders:
                    dice2.roll(order)
                if dice1.num == dice2.num:
                    checker = True
    
    for i in range(3):
        for j in range(3):
            for k in range(3):
                orders = "N" * (i + 1) + "E" * (j + 1) + "N" * (k + 1)
                # print(orders)
                
                for order in orders:
                    dice2.roll(order)
                if dice1.num == dice2.num:
                    checker = True
    return checker

# 2nd way
def check_dice_equal_2(dice1, dice2):
    checker = False
    num_dice1_top, num_dice1_front = dice1.num[0], dice1.num[1]
    
    index_top = dice2.num.index(num_dice1_top)
    index_front = dice2.num.index(num_dice1_front)
    
    counter = 0
    while (index_top != 0) & (counter < 3):
        counter += 1
        if index_top in [0, 1, 4, 5]:
            dice2.roll("N")
            index_top = dice2.num.index(num_dice1_top)
            index_front = dice2.num.index(num_dice1_front)
        else:
            dice2.roll("E")
            index_top = dice2.num.index(num_dice1_top)
            index_front = dice2.num.index(num_dice1_front)
    
    counter = 0
    while (index_front != 1) & (counter < 3):
            dice2.roll("rot_Clock")
            index_top = dice2.num.index(num_dice1_top)
            index_front = dice2.num.index(num_dice1_front)
    
    # print(f"dice1: {dice1.num}")
    # print(f"dice2: {dice2.num}")
    
    if dice1.num == dice2.num:
        checker = True
        
    return checker


# Main
ans_checker = True
for i in range(len(list_dice) - 1):
    for j in range(len(list_dice) - i - 1):
        j2 = j + (i + 1)
        dice1 = list_dice[i]
        dice2 = list_dice[j2]
        
        checker1 = check_dice_equal_1(dice1, dice2)
        checker2 = check_dice_equal_1(dice1, dice2)
        
        # どちらかがTrue(同じサイコロならFalse)
        if checker1 or checker2:
            ans_checker = False
    
if ans_checker:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
class dice:
    def __init__(self,label):
        self.top, self.front, self.right, self.left, self.rear, self.bottom = label
  
    def roll(self,op):
        if   op=='N': self.top, self.front, self.bottom, self.rear = self.front, self.bottom, self.rear , self.top
        elif op=='E': self.top, self.left , self.bottom, self.right = self.left , self.bottom, self.right, self.top
        elif op=='W': self.top, self.right, self.bottom, self.left = self.right, self.bottom, self.left , self.top
        elif op=='S': self.top, self.rear , self.bottom, self.front = self.rear , self.bottom, self.front, self.top
  
    def print_top(self): 
        print(self.top)
    def print_right(self): 
        print(self.right)
  
    def get_label(self):
        return [self.top, self.front, self.right, self.left, self.rear, self.bottom]
 
    def compare(self, label):
        for op in 'EEENEEENEEESEEESEEENEEEN':
            if self.get_label() == label:
                return True
            self.roll(op)
        else:
            return False
   
if __name__=='__main__':
    n = int(input())
    L = []
    for i in range(n):
        label = list(map(int,input().split()))
        for d in L:
            if d.compare(label): 
                break
        else:
            L.append(dice(label))
            continue
        print('No')
        break
    else:
        print('Yes')

Submission status: Accepted

Solution code:
from enum import Enum
import sys
import math

BIG_NUM = 2000000000
MOD = 1000000007
EPS = 0.000000001

# 0:中央 1:南 2:東 3:西 4:北 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):
        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])

    def equals(self, another):

        ret = False

        for i in range(len(self.order)):
            self.roll(self.order[i])
            FLG = True
            for k in range(6):
                if self.number[k] != another.number[k]:
                    FLG = False
                    break
            if FLG == True:
                return True

        return ret


num_dice = int(input())
DICE = []

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

FLG = True

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


if FLG == True:
    print("Yes")
else:
    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)]
        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):
        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])

    def equals(self, another):

        ret = False;

        for i in range(len(self.order)):
            self.roll(self.order[i])
            FLG = True
            for k in range(6):
                if self.number[k] != another.number[k]:
                    FLG = False
                    break
            if FLG == True:
                return True

        return ret


num_dice = int(input())
DICE = []

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

FLG = True

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

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