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:


class Dice:
    def __init__(self):
        self.diceNum: List[int] = [] 

    def setNum(self,i):
        self.pos = i[0]
        self.diceNum.append(i[0])
        self.diceNum.append(i[1])
        self.diceNum.append(i[2])
        self.diceNum.append(i[3])
        self.diceNum.append(i[4])
        self.diceNum.append(i[5])
    def getTopPos(self):
        return self.diceNum[0]    
    def moveToTopnum(self,n):
        i = 0
        for i in range(0,4):
            if (self.getTopPos() == n ):
                return True
            self.move("S")
        else:
            for j in range(0,4):
                if (self.getTopPos() == n ):
                    return True
                self.move("E")
        return False
    def getFrontPos(self):
        return self.diceNum[1]
    def getRightPos(self):
        return self.diceNum[2]
    def yokoRotate(self):
            i0=self.diceNum[0]
            i1=self.diceNum[2] 
            i2=self.diceNum[4] 
            i3=self.diceNum[1]
            i4=self.diceNum[3]
            i5=self.diceNum[5]
            self.diceNum =[i0,i1,i2,i3,i4,i5]
    def move(self,d):
        if (d == "E"):
            i0=self.diceNum[3]
            i1=self.diceNum[1] 
            i2=self.diceNum[0] 
            i3=self.diceNum[5]
            i4=self.diceNum[4]
            i5=self.diceNum[2]
            self.diceNum =[i0,i1,i2,i3,i4,i5]
        if (d == "W"):
            i0=self.diceNum[2]
            i1=self.diceNum[1] 
            i2=self.diceNum[5] 
            i3=self.diceNum[0]
            i4=self.diceNum[4]
            i5=self.diceNum[3]
            self.diceNum =[i0,i1,i2,i3,i4,i5]
        if (d == "S"):
            i0=self.diceNum[4]
            i1=self.diceNum[0] 
            i2=self.diceNum[2] 
            i3=self.diceNum[3]
            i4=self.diceNum[5]
            i5=self.diceNum[1]
            self.diceNum =[i0,i1,i2,i3,i4,i5]
        if (d == "N"):
            i0=self.diceNum[1]
            i1=self.diceNum[5] 
            i2=self.diceNum[2] 
            i3=self.diceNum[3]
            i4=self.diceNum[0]
            i5=self.diceNum[4]
            self.diceNum =[i0,i1,i2,i3,i4,i5]
    def rotateToFrontnum(self,n):
        for i in range(0,4):
            self.yokoRotate()
            if ( self.getFrontPos() == n):
                return True
        return False
    def isEqual(self,d):
        for i in range(0,6):
            if (self.diceNum[i] != d.diceNum[i]):
                return False
        return True

n = int(input())
l = list(map(int,input().split()))
dice = Dice()
dice.setNum(l)

min = 1000
r_num = 0
for i in set(l):
    if (min > l.count(i)):
       min = l.count(i)
       r_num = i
dice.moveToTopnum(r_num)

ans = "Yes"
for i in range(0,n-1):
    l2 = list(map(int,input().split()))
    dice2 = Dice()
    dice2.setNum(l2)

    t = dice.getTopPos()
    f = dice.getFrontPos()
    r = dice.getRightPos()
    #print ("test0:",t,f,r)
    if (dice2.moveToTopnum(t) == False ):
         continue
    #    print ("t1")
    elif (dice2.rotateToFrontnum(f) == False):
        continue
    #    print ("t2")
    elif (dice.isEqual(dice2) == False ):
        continue
    # print ("t3")
    else:
        ans = "No"  
        continue
    #print (dice.diceNum)
    #print (dice2.diceNum)

print (ans)

Submission status: Accepted

Solution code:
n=int(input())
d={i:list(input().split()) for i in range(n)}

def roll(Dice,Vector):
    if Vector == "N":
        c=Dice[0]
        Dice[0]=Dice[1]
        Dice[1]=Dice[5]
        Dice[5]=Dice[4]
        Dice[4]=c
    elif Vector == "W":
        c=Dice[0]
        Dice[0]=Dice[2]
        Dice[2]=Dice[5]
        Dice[5]=Dice[3]
        Dice[3]=c
    elif Vector == "E":
        c=Dice[0]
        Dice[0]=Dice[3]
        Dice[3]=Dice[5]
        Dice[5]=Dice[2]
        Dice[2]=c
    elif Vector == "S":
        c=Dice[0]
        Dice[0]=Dice[4]
        Dice[4]=Dice[5]
        Dice[5]=Dice[1]
        Dice[1]=c

v=list("NNNNWNNNWNNNENNNENNNWNNN")
f=0
for i in range(n):
    if f==0:
        for item in v:
            roll(d[i],item)
            if f==0:
                for j in range(i+1,n):
                    if d[i]==d[j]:
                        f+=1
                        break
if f==0:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
n = int(input())
slist = "NNNNWNNNNWNNNNWNNNNSNNNNWNNNNWNNNNWNNNNSNNNNWNNNNWNNNNWNNNNSNNNNWNNNNWNNNNWNNNN"

mat = [[0 for i in range(n)] for j in range(n)]
for i in range(n):
    mat[i] = list(map(int, input().split()))

for i in range(n):
    for j in range(i+1, n):
        for s in slist:
            if s == "N":
                next = list("263415")
            elif s == "E":
                next = list("421653")
            elif s == "S":
                next = list("513462")
            else:
                next = list("326154")

            tmp = [0] * 6
            for k, nex in enumerate(next):
                tmp[k] = mat[j][int(nex)-1]

            mat[j] = tmp

            if mat[i] == mat[j]:
                print("No")
                exit()

print("Yes")

Submission status: Accepted

Solution code:
n=int(input())
e=[[0 for i in range(6)]for j in range(n)]
for i in range(n):
	a=list(map(int,input().split()))
	e[i]=a	
for i in range(n-1):
	if e[0][0]==e[i+1][1]:
		e[i+1][0],e[i+1][1],e[i+1][4],e[i+1][5]=e[i+1][1],e[i+1][5],e[i+1][0],e[i+1][4]		
	elif e[0][0]==e[i+1][2]:
		e[i+1][0],e[i+1][2],e[i+1][3],e[i+1][5]=e[i+1][2],e[i+1][5],e[i+1][0],e[i+1][3]
	elif e[0][0]==e[i+1][3]:
		e[i+1][0],e[i+1][2],e[i+1][3],e[i+1][5]=e[i+1][3],e[i+1][0],e[i+1][5],e[i+1][2]	
	elif e[0][0]==e[i+1][4]:
		e[i+1][0],e[i+1][1],e[i+1][4],e[i+1][5]=e[i+1][4],e[i+1][0],e[i+1][5],e[i+1][1]		
	elif e[0][0]==e[i+1][5]:
		e[i+1][0],e[i+1][1],e[i+1][4],e[i+1][5]=e[i+1][5],e[i+1][4],e[i+1][1],e[i+1][0]
		
	for k in range(4):
		if 	e[0][1]!=e[i+1][1]:
			e[i+1][1],e[i+1][2],e[i+1][4],e[i+1][3]=e[i+1][3],e[i+1][1],e[i+1][2],e[i+1][4]
		else:
			break
count=0
for i in range(n):
	for j in range(n):
		if e[i]==e[j]:
			count=count+1
if count==n:
	print('Yes')
else:
	print('No')

Submission status: Accepted

Solution code:
n = int(input())
d_L = [list(map(int, input().split())) for i in range(n)]  
from collections import OrderedDict
def make_p(d):
    p = OrderedDict()
    for k, v in zip(["T", "N", "S", "E", "W", "B"], [d[0], d[4], d[1], d[2], d[3], d[5]]):
        p[k] = v
    return p
def judge_dice(d, d2):
    p, p2 = make_p(d), make_p(d2)
    for c in "SSSWNNNWNNNESSSWNNNESSSX":       
        t, n, s, e, w, b = p["T"], p["N"], p["S"], p["E"], p["W"], p["B"]
        if p == p2:
            return 0
            break
        if c == "N":
            p["N"], p["T"], p["S"], p["B"]= t, s, b, n
        if c == "S":
            p["N"], p["T"], p["S"], p["B"]= b, n, t, s
        if c == "E":
            p["E"], p["T"], p["W"], p["B"]= t, w, b, e
        if c == "W":
            p["E"], p["T"], p["W"], p["B"]= b, e, t, w       
         
for i, d in enumerate(d_L):
    if d == d_L[-1]:
        print("Yes")
    for d2 in d_L[i+1:]:
        if judge_dice(d, d2) == 0:
            print("No")
            break
    else:
        continue
    break

Submission status: Accepted

Solution code:
import sys

def swap(dice,i,j,k,l):#diceの目をi→ｊ→ｋ→ｌ→iの順に入れ替える
    x=dice[l]
    dice[l]=dice[k]
    dice[k]=dice[j]
    dice[j]=dice[i]
    dice[i]=x
    return dice

def Sroll(dice):
    dice=swap(dice,0,1,5,4)
    return dice

def Eroll(dice):
    dice=swap(dice,0,2,5,3)
    return dice

def Wroll(dice):
    dice=swap(dice,0,3,5,2)
    return dice

def Nroll(dice):
    dice=swap(dice,0,4,5,1)
    return dice


def judge(dice1,dice2):#2つのダイスが同じなら１を返し、違うなら０を返す
    top=dice1[0]
    fro=dice1[1]

    for j in range(0,8):
        if(fro==dice2[1]):
            break
        if(j==3):
            dice2=Eroll(dice2)
        if(j==7):
            return 0
        dice2=Sroll(dice2)
        
    i=0
    while(top!=dice2[0]):
        dice2=Eroll(dice2)
        if(i==3):
             return 0
        i+=1


    if(dice1[2]==dice2[2] and dice1[3]==dice2[3] and dice1[4]==dice2[4] and dice1[5]==dice2[5]):
        return 1
    else:
        return 0


n=int(input())

if(n==1):
    print("Yes")
    sys.exit()

Dice=[[]]

for i in range(0,n):
    Dice.append(list(map(int,input().split())))
del Dice[0]

for i in range(0,n):
    for j in range(i+1,n):
        if(judge(Dice[i],Dice[j])):
            print("No")
            sys.exit()


print("Yes")

Submission status: Accepted

Solution code:
from enum import Enum
import sys
import math

# 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.pattern = 'NNNNENNNENNNWNNNWNNNENNN'
        self.ret = 0
        
    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 match(self, Std):
        for i in range(6):
            self.work[i] = self.number[i]
        
        for i in range(len(self.pattern)):
            self.roll(self.pattern[i])
            if self.number == Std:
                self.ret = 1
                break
                
    def get_ret(self):
        return self.ret

total = 0
n = int(input())
dice = [''] * n

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

for i in range(1, n):
    dice[i].match(dice[0].number)

for i in range(1, n):
    total += int(dice[i].ret)

if total > 0:
    print('No')
else:
    print('Yes')

Submission status: Accepted

Solution code:
def cmp_dice(a, b):
    for _ in range(4):
        b[0],b[4],b[5],b[1]=b[1],b[0],b[4],b[5]
        for _ in range(4):
            b[1],b[2],b[4],b[3]=b[3],b[1],b[2],b[4]
            for _ in range(4):
                b[0],b[4],b[5],b[1]=b[1],b[0],b[4],b[5]
                if a==b:
                    return True
    return False

dd = []
for _ in range(int(input())):
    dd.append([int(i)-1 for i in input().split()])

for i in range(len(dd)-1):
    for j in range(i+1, len(dd)):
        if cmp_dice(dd[i],dd[j]):
            print('No')
            exit()
print('Yes')

Submission status: Accepted

Solution code:
class Dice :
    def __init__(self, pane):
        self.pane = pane
    
    def roll_W(self):
        temp = self.pane[0]
        self.pane[0] = self.pane[2]
        self.pane[2] = self.pane[5]
        self.pane[5] = self.pane[3]
        self.pane[3] = temp

    def roll_S(self):
        temp = self.pane[0]
        self.pane[0] = self.pane[4]
        self.pane[4] = self.pane[5]
        self.pane[5] = self.pane[1]
        self.pane[1] = temp

n = int(input())
dice = []
for i in range(0, n):
    dice.append(Dice(input().split()))  

flag = False
for k in range(0, n):
    for i in range(k + 1, n):
        count = 0
        while True:
            t = dice[k].pane[0]
            f = dice[k].pane[1]
            if (dice[i].pane[0] == f or dice[i].pane[4] == f):
                dice[i].roll_S()
            if (dice[i].pane[0] == t and dice[i].pane[1] == f):
                break
            if (count >= 8):
                break
            count += 1
            dice[i].roll_W()

        for j in range(0, len(dice[k].pane)):
            if (dice[k].pane[j] != dice[i].pane[j]):
                break
            if (j == len(dice[k].pane) - 1):
                flag = True

        if (flag):
            break

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

Submission status: Accepted

Solution code:
class Dice:
    def __init__(self, pip):
        self.pip = pip
    
    def move(self, dir):
        if str(dir) == 'E':
            self.pip[0], self.pip[2], self.pip[3], self.pip[5] = \
                self.pip[3], self.pip[0], self.pip[5], self.pip[2]
        elif str(dir) == 'W':
            self.pip[0], self.pip[2], self.pip[3], self.pip[5] = \
                self.pip[2], self.pip[5], self.pip[0], self.pip[3]
        elif str(dir) == 'N':
            self.pip[0], self.pip[1], self.pip[4], self.pip[5] = \
                self.pip[1], self.pip[5], self.pip[0], self.pip[4]
        elif str(dir) == 'S':
            self.pip[0], self.pip[1], self.pip[4], self.pip[5] = \
                self.pip[4], self.pip[0], self.pip[5], self.pip[1]


n = int(input())
dices = [Dice(list(map(int, input().split()))) for _ in range(n)]
check = "Yes"

for i in range(len(dices)-1):
    for j in range(i+1, len(dices)):
        tmp = Dice(dices[j].pip)
        for x in "EEENEEENEEESEEESEEENEEEN":
            if dices[i].pip == tmp.pip:
                check = "No"
                break
            tmp.move(x)
print(check)

Submission status: Accepted

Solution code:
class Dice:
    def __init__(self, nums):
        self.top    = nums[0]
        self.front  = nums[1]
        self.right  = nums[2]
        self.left   = nums[3]
        self.back   = nums[4]
        self.bottom = nums[5]

    def toN(self):
        tmp = self.top
        self.top = self.front
        self.front = self.bottom
        self.bottom = self.back
        self.back = tmp

    def toS(self):
        tmp = self.top
        self.top = self.back
        self.back = self.bottom
        self.bottom = self.front
        self.front = tmp

    def toE(self):
        tmp = self.top
        self.top = self.left
        self.left = self.bottom
        self.bottom = self.right
        self.right = tmp

    def toW(self):
        tmp = self.top
        self.top = self.right
        self.right = self.bottom
        self.bottom = self.left
        self.left = tmp

    def moveTo(self, ds):
        for d in ds:
            if   d == 'N':
                self.toN()
            if d == 'S':
                self.toS()
            if d == 'E':
                self.toE()
            if d == 'W':
                self.toW()

    def getTop(self):
        return self.top

    def getBottom(self):
        return self.bottom

    def getFront(self):
        return self.front

    def getBack(self):
        return self.back

    def getLeft(self):
        return self.left

    def getRight(self):
        return self.right

    def __eq__(self, other):
        if self.top != other.top:
            return False
        if self.bottom != other.bottom:
            return False
        if self.front != other.front:
            return False
        if self.back != other.back:
            return False
        if self.left != other.left:
            return False
        if self.right != other.right:
            return False

        return True

def moveTo(dice, top, front):
    if dice.getFront() != front:
        if   dice.getTop()    == front:
            dice.moveTo("S")
        elif dice.getBottom() == front:
            dice.moveTo("N")
        elif dice.getBack()   == front:
            dice.moveTo("NN")
        elif dice.getLeft()   == front:
            dice.moveTo("ES")
        elif dice.getRight()  == front:
            dice.moveTo("WS")

    if dice.getTop() != top:
        if   dice.getBottom() == top:
            dice.moveTo("EE")
        elif dice.getLeft()   == top:
            dice.moveTo("E")
        elif dice.getRight()  == top:
            dice.moveTo("W")

    return dice

def equalDice(dice1, dice2):
    dice2 = moveTo(dice2, dice1.getTop(), dice1.getFront())
    return dice1 == dice2

def main():
    n = int(input())
    dice1 = Dice(input().split())

    ans = "Yes"
    for _ in range(n-1):
        dice2 = Dice(input().split())

        if equalDice(dice1, dice2):
            ans = "No"
            break

    print(ans)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
class Dice:
  def __init__(self, top=1, front=2, left=4, right=3, back=5, bottom=6):
    self.d = {"TOP":top, "FRONT":front, "LEFT":left, "RIGHT":right, "BACK":back, "BOTTOM":bottom}

  def roll_x(self):
    self._roll("TOP", "FRONT", "BOTTOM", "BACK")
  
  def roll_y(self):
    self._roll("FRONT", "LEFT", "BACK", "RIGHT")
  
  def roll_z(self):
    self._roll("TOP", "LEFT", "BOTTOM", "RIGHT")
  
  def _roll(self, a, b, c, d):
    self.d[a], self.d[b], self.d[c], self.d[d] = \
    self.d[b], self.d[c], self.d[d], self.d[a]
  
  def all_rolls(self):
    ret = []
    for i in range(6):
      if i%2:
        self.roll_x()
      else:
        self.roll_y()
      for _ in range(4):
        self.roll_z()
        t = self.d.copy()
        ret.append(t)
    return ret

  def equivalent(self, dice):
    for i in range(6):
      if i%2:
        self.roll_x()
      else:
        self.roll_y()
      for _ in range(4):
        self.roll_z()
        t = self.d.copy()
        if t==dice.d:
          return True
    return False

n = int(input())
d = []
flag = False
for i in range(n):
  a = list(map(int, input().split()))
  d.append(Dice(a[0], a[1], a[3], a[2], a[4], a[5]))
for i in range(n):
  for j in range(i+1, n):
    if d[i].equivalent(d[j]):
      flag = True
      break
if flag:
  print("No")
else:
  print("Yes")

Submission status: Accepted

Solution code:
class Dice:
	# Label: 1=Up, 2=South, 3=East, 4=West, 5=North, 6=Down
	def __init__(self, nums):
		self.nums = nums
		self.cU = nums[0]
		self.cS = nums[1]
		self.cE = nums[2]
		self.cW = nums[3]
		self.cN = nums[4]
		self.cD = nums[5]
	def goN(self):
		pU,pS,pN,pD = self.cU,self.cS,self.cN,self.cD
		self.cU,self.cS,self.cN,self.cD = pS,pD,pU,pN
	def goE(self):
		pU,pE,pW,pD = self.cU,self.cE,self.cW,self.cD
		self.cU,self.cE,self.cW,self.cD = pW,pU,pD,pE
	def goW(self):
		pU,pE,pW,pD = self.cU,self.cE,self.cW,self.cD
		self.cU,self.cE,self.cW,self.cD = pE,pD,pU,pW
	def goS(self):
		pU,pS,pN,pD = self.cU,self.cS,self.cN,self.cD
		self.cU,self.cS,self.cN,self.cD = pN,pU,pD,pS
	def toU(self, num):
		if self.cD == num:
			for _ in range(2): self.goN()
		elif self.cN == num: self.goS()
		elif self.cE == num: self.goW()
		elif self.cW == num: self.goE()
		elif self.cS == num: self.goN()
	def right(self, num):
		if self.cN == num: return self.cW
		elif self.cE == num: return self.cN
		elif self.cW == num: return self.cS
		elif self.cS == num: return self.cE
		else: raise # ????????????
	def equals(self, dice):
		"""?????????????????¨????????????????????¢????????????????????§??¨???"""
		for i in self.nums:
			if dice.nums.count(i) == 1:
				self.toU(i)
				dice.toU(i)
				break
		if self.cU == dice.cU and self.cD == dice.cD:
			nesw1 = ''.join(list(map(str, [self.cN,self.cE,self.cS,self.cW])))
			nesw1 += nesw1
			nesw2 = ''.join(list(map(str, [dice.cN,dice.cE,dice.cS,dice.cW])))
			if nesw1.count(nesw2) > 0: return True
			else: return False
		else: return False
dice = [Dice(list(map(int, input().split(' ')))) for _ in range(int(input()))]
pre = None
rslt = True
for die in dice:
	if pre == None: 
		pre = die
		continue
	if pre.equals(die):
		rslt = False
		break
if rslt: print('Yes')
else: print('No')

Submission status: Runtime Error

Solution code:
class Dice(object):
 
    def __init__(self, d):

        self.rows = [d[0], d[4], d[5], d[1]]
        self.cols = [d[0], d[2], d[5], d[3]]
 
    def move_next_rows(self):
        temp = self.rows.pop(0)
        self.rows.append(temp)
        self.__update(self.cols, self.rows)

    def move_prev_rows(self):
        temp = self.rows.pop(3)
        self.rows.insert(0, temp)
        self.__update(self.cols, self.rows)
    
    def move_next_cols(self):
        temp = self.cols.pop(0)
        self.cols.append(temp)
        self.__update(self.rows, self.cols)
 
    def move_prev_cols(self):
        temp = self.cols.pop(3)
        self.cols.insert(0, temp)
        self.__update(self.rows, self.cols)

    def __update(self, x, y):
        x[0] = y[0]
        x[2] = y[2]
 
class DiceChecker(object):

    def __init__(self, dice1, dice2):
        self.dice1 = dice1
        self.dice2 = dice2
        self.dice1_top = self.dice1.rows[0]
        self.dice1_front = self.dice1.rows[3]
        
    def check_same_dice(self):

        is_same = False
        for _ in range(4):
            for _ in range(4):
                for _ in range(4):
                    is_same_element = self.dice1.rows == self.dice2.rows and self.dice1.cols == self.dice2.cols
                    if is_same_element: 
                        is_same = True
                    self.__rot(self.dice2)
                self.dice2.move_next_rows()
            self.dice2.move_next_cols()
            
        if is_same:
            return False
        else:
            return True
    
    def __rot(self, dice):
        temp = dice.rows[1]
        dice.rows[1] = dice.cols[3]
        dice.cols[3] = dice.rows[3]
        dice.rows[3] = dice.cols[1]
        dice.cols[1] = temp


j = int(input())
dice_list = []
src = []
for _ in range(j):
    d = list(map(int, input().split(" ")))
    dice_list.append(Dice(d))
    src.append(d)

is_diff = False
for dice1 in dice_list:
    src.pop(0)
    for dice in src:
        dice_checker = DiceChecker(dice1, dice)
        if(dice_checker.check_same_dice()):
            is_diff = True

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

Submission status: Runtime Error

Solution code:
class Dice(object):
 
    def __init__(self, d):

        self.rows = [d[0], d[4], d[5], d[1]]
        self.cols = [d[0], d[2], d[5], d[3]]
 
    def move_next_rows(self):
        temp = self.rows.pop(0)
        self.rows.append(temp)
        self.__update(self.cols, self.rows)

    def move_prev_rows(self):
        temp = self.rows.pop(3)
        self.rows.insert(0, temp)
        self.__update(self.cols, self.rows)
    
    def move_next_cols(self):
        temp = self.cols.pop(0)
        self.cols.append(temp)
        self.__update(self.rows, self.cols)
 
    def move_prev_cols(self):
        temp = self.cols.pop(3)
        self.cols.insert(0, temp)
        self.__update(self.rows, self.cols)

    def __update(self, x, y):
        x[0] = y[0]
        x[2] = y[2]
 
class DiceChecker(object):

    def __init__(self, dice1, dice2):
        self.dice1 = dice1
        self.dice2 = dice2
        self.dice1_top = self.dice1.rows[0]
        self.dice1_front = self.dice1.rows[3]
        
    def check_same_dice(self):

        is_same = False
        for _ in range(4):
            for _ in range(4):
                for _ in range(4):
                    is_same_element = self.dice1.rows == self.dice2.rows and self.dice1.cols == self.dice2.cols
                    if is_same_element: 
                        is_same = True
                    self.__rot(self.dice2)
                self.dice2.move_next_rows()
            self.dice2.move_next_cols()
            
        if is_same:
            return False
        else:
            return True
    
    def __rot(self, dice):
        temp = dice.rows[1]
        dice.rows[1] = dice.cols[3]
        dice.cols[3] = dice.rows[3]
        dice.rows[3] = dice.cols[1]
        dice.cols[1] = temp


j = int(input())
dice_list = []
src = []
for _ in range(j):
    d = list(map(int, input().split(" ")))
    dice_list.append(Dice(d))
    src.append(Dice(d)

is_diff = False
for dice1 in dice_list:
    src.pop(0)
    for dice in src:
        dice_checker = DiceChecker(dice1, dice)
        if(dice_checker.check_same_dice()):
            is_diff = True

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

Submission status: Runtime Error

Solution code:
from enum import Enum
import sys
import math

#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 query(self,top_num,front_num):
        self.save_data = [i for i in range(6)]
        for i in range(len(self.number)):
            self.save_data[i] = self.number[i]
        ret =-1

        for i in range(len(self.order)):
            self.roll(self.order[i])
            if self.number[0] == top_num and self.number[1] == front_num:
                ret = self.number[2]
                break
        for i in range(len(self.number)):
            self.number[i] = self.save_data[i]

    def equal(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].equal(Dice[k])==True:
            FLG = False
            break
            
if FLG == True:
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:
class Dice():
	def __init__(self):
		self.number = [_ for _ in range(6)]
		self.work = [_ for _ 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 _ in range(6):
			self.work[_] = self.number[_]
		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 get_top(self):
		return self.number[0]
	def get_right(self,n1,n2):
		if(n1 == self.number[0]):
			if(n2 == self.number[1]): return(self.number[2])
			elif(n2 == self.number[2]): return(self.number[4])
			elif(n2 == self.number[3]): return(self.number[1])
			elif(n2 == self.number[4]): return(self.number[3])
		elif(n1 == self.number[1]):
                        if(n2 == self.number[0]): return(self.number[3])
                        elif(n2 == self.number[2]): return(self.number[0])
                        elif(n2 == self.number[3]): return(self.number[5])
                        elif(n2 == self.number[5]): return(self.number[2])
		elif(n1 == self.number[2]):
                        if(n2 == self.number[0]): return(self.number[1])
                        elif(n2 == self.number[1]): return(self.number[5])
                        elif(n2 == self.number[4]): return(self.number[0])
                        elif(n2 == self.number[5]): return(self.number[4])
		elif(n1 == self.number[3]):
                        if(n2 == self.number[0]): return(self.number[4])
                        elif(n2 == self.number[1]): return(self.number[0])
                        elif(n2 == self.number[4]): return(self.number[5])
                        elif(n2 == self.number[5]): return(self.number[1])
		elif(n1 == self.number[4]):
                        if(n2 == self.number[0]): return(self.number[2])
                        elif(n2 == self.number[2]): return(self.number[5])
                        elif(n2 == self.number[3]): return(self.number[0])
                        elif(n2 == self.number[5]): return(self.number[3])
		elif(n1 == self.number[5]):
                        if(n2 == self.number[1]): return(self.number[3])
                        elif(n2 == self.number[2]): return(self.number[1])
                        elif(n2 == self.number[3]): return(self.number[4])
                        elif(n2 == self.number[4]): return(self.number[2])

	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

n = int(input())
dice = []
for _ in range(n):
	data = list(map(int,input().split()))
	dice.append(Dice())
	dice[_].setNumber(data[0],data[1],data[2],data[3],data[4],data[5])


if(dice[0].equals(dice[1]) == dice[0].equals(dice[2])):
	print("Yes")
else:
	print("No")