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:
n = int(input())
dice_list = [list(map(int,input().split())) for i in range(n)]

pattern_list =[[0,1,2,3,4,5],[0,2,4,1,3,5],[0,4,3,2,1,5],[0,3,1,4,2,5],[1,2,0,5,3,4],[1,5,2,3,0,4],[1,3,5,0,2,4],[1,0,3,2,5,4],[2,0,1,4,5,3],[2,4,0,5,1,3],[2,5,4,1,0,3],[2,1,5,0,4,3],[3,0,4,1,5,2],[3,1,0,5,4,2],[3,5,1,4,0,2],[3,4,5,0,1,2],[4,2,5,0,3,1],[4,0,2,3,5,1],[4,3,0,5,2,1],[4,5,3,2,0,1],[5,1,3,2,4,0],[5,2,1,4,3,0],[5,4,2,3,1,0],[5,3,4,1,2,0]]

dice_c_list =[0,0,0,0,0,0]
cnt = 0

for g in range(n-1):
	h = g+1
	while h < n:
		for i in range(24):
			for j in range(6):
				dice_c_list[j]=  dice_list[g][pattern_list[i][j]]
			if dice_c_list == dice_list[h]:
				cnt =1
				break
		h +=1
if cnt==0:
	print("Yes")
else:
	print("No")

Submission status: Accepted

Solution code:
class Dice:
    
    def __init__(self, lst):
        self.val=[]
        self.val.append(lst[0])
        self.val.append(lst[1])
        self.val.append(lst[2])
        self.val.append(lst[3])
        self.val.append(lst[4])
        self.val.append(lst[5])

    def rotate(self,dir):
        if dir=="N":
            tmp=self.val[0]
            self.val[0]=self.val[1]
            self.val[1]=self.val[5]
            self.val[5]=self.val[4]
            self.val[4]=tmp
        if dir=="E":
            tmp=self.val[0]
            self.val[0]=self.val[3]
            self.val[3]=self.val[5]
            self.val[5]=self.val[2]
            self.val[2]=tmp
        if dir=="S":
            tmp=self.val[0]
            self.val[0]=self.val[4]
            self.val[4]=self.val[5]
            self.val[5]=self.val[1]
            self.val[1]=tmp
        if dir=="W":
            tmp=self.val[0]
            self.val[0]=self.val[2]
            self.val[2]=self.val[5]
            self.val[5]=self.val[3]
            self.val[3]=tmp

def int_to_dir(n):
    if n==0:
        return "N"
    if n==1:
        return "E"
    if n==2:
        return "S"
    if n==3:
        return "W"

import random 

def areSame(D1,D2):
    Determin=False
    for i in range(100):

        D2.rotate(int_to_dir(random.randint(0,4)))

        if D1.val==D2.val:
            Determin=True

    return Determin
    
    
n = int(input())
Instance=[]
for i in range(n):
    x = list(map(int,input().split()))
    Instance.append(Dice(x))
    #print(Instance)
    #print("val:",Instance[i].val)
    #print(Instace[i].val)

Ans=True
for i in range(n-1):
    for j in range(i+1,n):
        D1=Instance[i]
        D2=Instance[j]
        if areSame(D1,D2):
            Ans=False

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

Submission status: Accepted

Solution code:
def dice_rotation(dice, command):

	tmp_dice = []
	
	for i in range(6):
		tmp_dice.append(dice[i])

	#S:1->2,2->6,6->5,5->1
	if command == 'S':
		dice[0] = tmp_dice[4]
		dice[4] = tmp_dice[5]
		dice[5] = tmp_dice[1]
		dice[1] = tmp_dice[0]
	#N:1->5,5->6,6->2,2->1
	elif command == 'N':
		dice[0] = tmp_dice[1]
		dice[1] = tmp_dice[5]
		dice[5] = tmp_dice[4]
		dice[4] = tmp_dice[0]
	#W:1->4,4->6,6->3,3->1
	elif command == 'W':
		dice[0] = tmp_dice[2]
		dice[2] = tmp_dice[5]
		dice[5] = tmp_dice[3]
		dice[3] = tmp_dice[0]
	#E:1->3,3->6,6->4,4->1
	elif command == 'E':
		dice[0] = tmp_dice[3]
		dice[3] = tmp_dice[5]
		dice[5] = tmp_dice[2]
		dice[2] = tmp_dice[0]

def dice_spinning(dice):

	tmp_dice = []
	
	for i in range(6):
		tmp_dice.append(dice[i])

	dice[1] = tmp_dice[2]
	dice[2] = tmp_dice[4]
	dice[4] = tmp_dice[3]
	dice[3] = tmp_dice[1]

def comparison_dices(Dice1,Dice2):

	yes_counter = 0
	for j in range(6):
		if Dice1[j] == Dice2[j]:
			yes_counter += 1
	if yes_counter == 6:
		return True

	return False

def full_validation_dices(Dice1,Dice2):

	judgement_result = False

	#1st direction
	for i in range(4):
		for j in range(4):
			if comparison_dices(Dice1,Dice2) == True:
				judgement_result = True
				break
			else:
				dice_spinning(Dice2)

		if judgement_result == True:
			break
		else:
			dice_rotation(Dice2,'S')

	#2nd direction
	for i in range(4):
		for j in range(4):
			if comparison_dices(Dice1,Dice2) == True:
				judgement_result = True
				break
			else:
				dice_spinning(Dice2)

		if judgement_result == True:
			break
		else:
			dice_rotation(Dice2,'W')

	if judgement_result == True:
		return True
	else:
		return False


def test():

	n = int(input())

	Dices = []

	result = True

	for i in range(n):

		tmp_dice = list(map(int,input().split()))
		Dices.append(tmp_dice)
	
	for i in range(n-1):
		for j in range(i+1,n):
			if full_validation_dices(Dices[i],Dices[j]) == True:
				result = False
				break
		if result == False:
			break

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


if __name__ == "__main__":
	test()

Submission status: Accepted

Solution code:
import copy


class Dice:
    def __init__(self, a, b, c, d, e, f):
        self.top = a
        self.front = b
        self.right = c
        self.left = d
        self.behind = e
        self.bottom = f

    def S(self):
        self.top, self.front, self.behind, self.bottom = self.behind, self.top, self.bottom, self.front

    def N(self):
        self.behind, self.top, self.bottom, self.front = self.top, self.front, self.behind, self.bottom

    def E(self):
        self.top, self.bottom, self.left, self.right = self.left, self.right, self.bottom, self.top

    def W(self):
        self.left, self.right, self.bottom, self.top = self.top, self.bottom, self.left, self.right

    def spin(self):
        self.left, self.behind, self.right, self.front = self.front, self.left, self.behind, self.right

    def __eq__(self, _dice2):
        dice2 = copy.deepcopy(_dice2)
        for i in range(4):
            if self._eqaul(dice2):
                return True
            dice2.spin()
        dice2 = copy.deepcopy(_dice2)
        dice2.N()
        dice2.N()
        for i in range(4):
            if self._eqaul(dice2):
                return True
            dice2.spin()
        dice2 = copy.deepcopy(_dice2)
        dice2.N()
        for i in range(4):
            if self._eqaul(dice2):
                return True
            dice2.spin()
        dice2 = copy.deepcopy(_dice2)
        dice2.E()
        for i in range(4):
            if self._eqaul(dice2):
                return True
            dice2.spin()
        dice2 = copy.deepcopy(_dice2)
        dice2.W()
        for i in range(4):
            if self._eqaul(dice2):
                return True
            dice2.spin()
        dice2 = copy.deepcopy(_dice2)
        dice2.S()
        for i in range(4):
            if self._eqaul(dice2):
                return True
            dice2.spin()
        return False

    def _eqaul(self, dice2):
        return self.front == dice2.front and self.behind == dice2.behind and self.left == dice2.left and self.right == dice2.right and self.top == dice2.top and self.bottom == dice2.bottom

    def __repr__(self):
        return ",".join([str(object=i) for i in (self.top, self.front, self.right, self.left, self.behind, self.bottom)])


n=int(input())
dices=[]
flag=False
for i in range(n):
    d=Dice(*[int(i) for i in input().split(" ")])
    for dice in dices:
        if d==dice:
            flag=True
            break
    dices.append(d)
if flag:
    print("No")
else:
    print("Yes")

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,odr):
        if   odr=='N': self.top, self.front, self.bottom, self.rear = \
                                self.front, self.bottom, self.rear , self.top
        elif odr=='E': self.top, self.left , self.bottom, self.right = \
                                self.left , self.bottom, self.right, self.top
        elif odr=='W': self.top, self.right, self.bottom, self.left = \
                                self.right, self.bottom, self.left , self.top
        elif odr=='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 odr in 'EEENEEENEEESEEESEEENEEEN':
            if self.get_label() == label:
                return True
            self.roll(odr)
        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:
#!/usr/bin/env python3
import sys
import copy

line = sys.stdin.readline() 

faces = []

def anydup(thelist): 
    seen = set() 
    for x in thelist: 
        if x in seen: 
            return True 
        seen.add(x) 
    return False

while(True):
    line = sys.stdin.readline() 
    if not line:
        break
    line = line.rstrip('\r\n')
    faces.append(line.split())

for i in range(5):
    face  = faces[-1]
    if face[0] != face[1]:
        break
    face_old = copy.deepcopy(face)
    face[0] = face_old[1]
    face[1] = face_old[5]
    face[2] = face_old[2]
    face[3] = face_old[3]
    face[4] = face_old[0]
    face[5] = face_old[4]
else:
    face_old = copy.deepcopy(face)
    face[0] = face_old[3]
    face[1] = face_old[1]
    face[2] = face_old[0]
    face[3] = face_old[5]
    face[4] = face_old[4]
    face[5] = face_old[2]
for i in range(5):
    if face[0] != face[1]:
        break
    face_old = copy.deepcopy(face)
    face[0] = face_old[1]
    face[1] = face_old[5]
    face[2] = face_old[2]
    face[3] = face_old[3]
    face[4] = face_old[0]
    face[5] = face_old[4]
for i in range(5):
    if face[0] != face[1]:
        break
    face_old = copy.deepcopy(face)
    face[0] = face_old[3]
    face[1] = face_old[1]
    face[2] = face_old[0]
    face[3] = face_old[5]
    face[4] = face_old[4]
    face[5] = face_old[2]

for j in range(len(faces) - 1):
    face  = faces[j]
    face2 = faces[-1]
    for i in range(5):
        if face[1] == face2[1]:
            break
        face_old = copy.deepcopy(face)
        face[0] = face_old[1]
        face[1] = face_old[5]
        face[2] = face_old[2]
        face[3] = face_old[3]
        face[4] = face_old[0]
        face[5] = face_old[4]
    else:
        face_old = copy.deepcopy(face)
        face[0] = face_old[3]
        face[1] = face_old[1]
        face[2] = face_old[0]
        face[3] = face_old[5]
        face[4] = face_old[4]
        face[5] = face_old[2]
    for i in range(5):
        if face[1] == face2[1]:
            break
        face_old = copy.deepcopy(face)
        face[0] = face_old[1]
        face[1] = face_old[5]
        face[2] = face_old[2]
        face[3] = face_old[3]
        face[4] = face_old[0]
        face[5] = face_old[4]
    for i in range(5):
        if face[0] == face2[0]:
            break
        face_old = copy.deepcopy(face)
        face[0] = face_old[3]
        face[1] = face_old[1]
        face[2] = face_old[0]
        face[3] = face_old[5]
        face[4] = face_old[4]
        face[5] = face_old[2]

#for f in faces:
#    print(f)

if any(faces.count(x) > 1 for x in faces):
    print("No")
else:
    print("Yes")

Submission status: Accepted

Solution code:
def west(d):
	tmp=d[4]
	d[4]=d[1]
	d[1]=d[3]
	d[3]=d[6]
	d[6]=tmp

def east(d):
	tmp=d[4]
	d[4]=d[6]
	d[6]=d[3]
	d[3]=d[1]
	d[1]=tmp

def north(d):
	tmp=d[1]
	d[1]=d[2]
	d[2]=d[6]
	d[6]=d[5]
	d[5]=tmp

def south(d):
	tmp=d[1]
	d[1]=d[5]
	d[5]=d[6]
	d[6]=d[2]
	d[2]=tmp

def spin(d):
	tmp=d[2]
	d[2]=d[3]
	d[3]=d[5]
	d[5]=d[4]
	d[4]=tmp

def kaiten(d, op):
	if   op == "W": west(d)
	elif op == "E": east(d)
	elif op == "N": north(d)
	elif op == "S": south(d)

def inputDice():
	return list(map(int,("-1 "+input()).split()))

def equal(da, db):
	for op in list("NWWWN-"):
		for i in range(4):
			if(da[1]==db[1] and da[2]==db[2] and da[3]==db[3] and da[4]==db[4] and da[5]==db[5] and da[6]==db[6]):
				return True
			spin(db)
		kaiten(db,op)
	return False

def yes(d):
	for i in range(n):
		for j in range(i):
			if equal(d[i], d[j]):
				return False
	return True

n=int(input())

d=[inputDice() for i in range(n)]

if yes(d):
	print("Yes")
else:
	print("No")

Submission status: Accepted

Solution code:
class dice:
  def __init__(self,dice_number_list):
    self.top,self.front,self.right,self.left,self.rear,self.bottom = dice_number_list
    self.dice_number_list = dice_number_list
    
  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])
    
  #全パターン24通りの取得(ソート済み)
  def get_all_number_list(self):
    all_dice_number_list = []
    for op in "NNNNWNNNWNNNENNNENNNWNNN":
      self.roll(op)
      if self.get_label() not in all_dice_number_list:
        all_dice_number_list.append(self.get_label())
    return(sorted(all_dice_number_list))
  
  #2つのサイコロの一致判定
  def judge_equal(self,another):
    if(self.get_all_number_list() == another.get_all_number_list()):
       return True
    else:
       return False
  
n = int(input())
dice_list=[[0,0,0,0,0,0]]*n

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

FLG=True
for i in range(n-1):
  for j in range(i+1,n):
    if dice_list[i].judge_equal(dice_list[j]):
      FLG=False
      break

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

Submission status: Accepted

Solution code:
n = int(input())
a = [0] * n
b = 1
for i in range(n):
    a[i] = list(map(int, input().split()))
for i in range(n - 1):
    for j in range(i + 1, n):
        for k in range(4):
            t = a[i][0]
            a[i][0] = a[i][1]
            a[i][1] = a[i][5]
            a[i][5] = a[i][4]
            a[i][4] = t
            for u in range(4):
                v = a[i][1]
                a[i][1] = a[i][2]
                a[i][2] = a[i][4]
                a[i][4] = a[i][3]
                a[i][3] = v
                if a[i] == a[j]:
                    b = 0
        for k in range(4):
            t = a[i][0]
            a[i][0] = a[i][2]
            a[i][2] = a[i][5]
            a[i][5] = a[i][3]
            a[i][3] = t
            for u in range(4):
                v = a[i][1]
                a[i][1] = a[i][2]
                a[i][2] = a[i][4]
                a[i][4] = a[i][3]
                a[i][3] = v
                if a[i] == a[j]:
                    b = 0
if b:
    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:
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:
def roll(die, d):
    if d == "E":
        return [die[3], die[1], die[0], die[5], die[4], die[2]]
    if d == "N":
        return [die[1], die[5], die[2], die[3], die[0], die[4]]
    if d == "S":
        return [die[4], die[0], die[2], die[3], die[5], die[1]]
    if d == "W":
        return [die[2], die[1], die[5], die[0], die[4], die[3]]
    if d == "L":
        return [die[0], die[3], die[1], die[4], die[2], die[5]]
    if d == "R":
        return [die[0], die[2], die[4], die[1], die[3], die[5]]
 
def checkdice(die1, die2):
    ans = False
    for d in "RRRNRRRNRRRSRRRSRRRNRRRR":
        if die1 == die2:
            ans = True
            break
        die2 = roll(die2, d)
    return ans
 
dice = []
msg = "Yes"
n = int(input())
for _ in range(n):
    dice.append(list(map(int, input().split())))
for i in range(n):
    for j in range(i + 1, n):
        if checkdice(dice[i], dice[j]):
            msg = "No"
            break
    if msg == "No":
        break
print(msg)

Submission status: Accepted

Solution code:
n = int(input())
a = [0] * n
b = 1
for i in range(n):
	a[i] = list(map(int, input().split()))
for i in range(n - 1):
	for j in range(i + 1, n):
		for k in range(4):
			t = a[i][0]
			a[i][0] = a[i][1]
			a[i][1] = a[i][5]
			a[i][5] = a[i][4]
			a[i][4] = t
			for u in range(4):
				v = a[i][1]
				a[i][1] = a[i][2]
				a[i][2] = a[i][4]
				a[i][4] = a[i][3]
				a[i][3] = v
				if a[i] == a[j]:
					b = 0
		for k in range(4):
			t = a[i][0]
			a[i][0] = a[i][2]
			a[i][2] = a[i][5]
			a[i][5] = a[i][3]
			a[i][3] = t
			for u in range(4):
				v = a[i][1]
				a[i][1] = a[i][2]
				a[i][2] = a[i][4]
				a[i][4] = a[i][3]
				a[i][3] = v
				if a[i] == a[j]:
					b = 0
if b:
	print("Yes")
else:
	print("No")

Submission status: Accepted

Solution code:
D = [
    (1, 5, 2, 3, 0, 4), # 'U'
    (3, 1, 0, 5, 4, 2), # 'R'
    (4, 0, 2, 3, 5, 1), # 'D'
    (2, 1, 5, 0, 4, 3), # 'L'
]
 
N = int(input())
L = [None]*N
for i in range(N):
    *L[i], = map(int, input().split())
 
p = (0, 0, 0, 1, 1, 2, 2, 3)
ok = 1
for i in range(N):
    Li = L[i]
    for j in range(i+1, N):
        Lj = L[j]
        for k in range(24):
            if Li == Lj:
                ok = 0
            Lj[:] = (Lj[e] for e in D[p[k%8]])
print("Yes" if ok else "No")

Submission status: Accepted

Solution code:
#! python3
# diceIV.py - サイコロを転がす動きをシミュレートするプログラム
import sys

def getKeyFromValue(dice, value):
    keys = [k for k, v in dice.items() if v == value]
    if keys:
        return keys[0]
    return None

def initDice(numbers):  # サイコロオブジェクトに値を入れる
        # サイコロオブジェクトを定義, 配列の数値を、各面にわたす
    dice = {'top': numbers[0], 'bottom': numbers[5], 'front': numbers[1],
            'back': numbers[4], 'right': numbers[2], 'left': numbers[3]}
    return dice


def rollDice(dice, direction):  # サイコロを転がしたときの関数
    if direction == 'N':
        top = dice['front']
        bottom = dice['back']
        front = dice['bottom']
        back = dice['top']
        dice['top'] = top
        dice['bottom'] = bottom
        dice['front'] = front
        dice['back'] = back
    elif direction == 'S':
        top = dice['back']
        bottom = dice['front']
        front = dice['top']
        back = dice['bottom']
        dice['top'] = top
        dice['bottom'] = bottom
        dice['front'] = front
        dice['back'] = back
    elif direction == 'E':
        top = dice['left']
        bottom = dice['right']
        right = dice['top']
        left = dice['bottom']
        dice['top'] = top
        dice['bottom'] = bottom
        dice['right'] = right
        dice['left'] = left
    elif direction == 'W':
        top = dice['right']
        bottom = dice['left']
        right = dice['bottom']
        left = dice['top']
        dice['top'] = top
        dice['bottom'] = bottom
        dice['right'] = right
        dice['left'] = left
    return dice


def spinDice(dice):
    front = dice['right']
    right = dice['back']
    back = dice['left']
    left = dice['front']
    dice['front'] = front
    dice['right'] = right
    dice['back'] = back
    dice['left'] = left
    return dice

def assertDice(dice_1, dice_2):
    if dice_1 == dice_2:
        print('No')
        sys.exit()

# 一つの目でやるチェックをまとめる
def checkDice(dice_1,dice_2):
    assertDice(dice_1, dice_2)
    for i in range(3):
        dice_1 = spinDice(dice_1)
        assertDice(dice_1, dice_2)

def diceIII(dice_1, dice_2):
    checkDice(dice_1,dice_2)

    roll_directions = [['N'], ['S'], ['W'],['E'],['N','N']]

    dice_1 = initDice(numbers_1)

    for direction in roll_directions:
        for d in direction:
            dice_1 = rollDice(dice_1, d)
        checkDice(dice_1,dice_2)
        dice_1 = initDice(numbers_1)

n = int(input())
all_dice_numbers = []
for i in range(n):
  numbers = [int(i) for i in input().split()]
  all_dice_numbers.append(numbers)

for i in range(n):
  numbers_1 = all_dice_numbers[i]
  dice_1 = initDice(numbers_1)

  for j in range(i+1, n):
    if j == n:
      pass
    else :
      numbers_2 = all_dice_numbers[j]
      dice_2 = initDice(numbers_2)
      diceIII(dice_1, dice_2)

print('Yes')

Submission status: Accepted

Solution code:

def inputTable(a):
	lit=[]
	for aa in range(a):
		lit.append(list(map(int,input().split())))
	return lit

def kouten(dai):
	x=dai[0]
	dai[0]=dai[1]
	dai[1]=dai[5]
	dai[5]=dai[4]
	dai[4]=x
	return(dai)
def sokuten(dai):
	x=dai[0]
	dai[0]=dai[2]
	dai[2]=dai[5]
	dai[5]=dai[3]
	dai[3]=x
	return(dai)

def tokei(dai):
	dai1 = dai[1]
	dai[1] = dai[2]
	dai[2] = dai[4]
	dai[4] = dai[3]
	dai[3] = dai1
	return(dai)

def check(dai,daini):
	for j in range(4):
		if daini[0] == dai[0] and daini[1] == dai[1] and daini[2] == dai[2] and daini[3] == dai[3] and daini[4] == dai[4] and daini[5] == dai[5]:
			print('No')
			return True
		tokei(dai)
	return False

def checkup(a,b):
	for unuse in range(3):
		if not check(a,b):
			kouten(a)
		else:
			return True
		if not check(a,b):
			sokuten(a)
			if unuse==2 :
				if	not check(a,b) :
					return	False  
		else:
			return True

n=int(input())
daise=inputTable(n)
k=0
R=0
for cc in range(n):
	if k==1:
		break
	for dd in range(cc+1,n):
		if k==1:
			break
		if   checkup(daise[cc],daise[dd]):
			k=1
			break
		
if k==R:
	print('Yes')

Submission status: Accepted

Solution code:
import copy

class Dice:
    # 0: top, 1: front, 2: right, 3: left, 4: back, 5: bottom
    def __init__(self, n0, n1, n2, n3, n4, n5):
        self.faces = [n0, n1, n2, n3, n4, n5]

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

    def spin_horizontally(self):
        tmp = self.faces[1]
        self.faces[1] = self.faces[2]
        self.faces[2] = self.faces[4]
        self.faces[4] = self.faces[3]
        self.faces[3] = tmp

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

    def front(self):
        return self.faces[1]

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

    def equals(self, other_dice):
        dice = copy.deepcopy(other_dice)
        flg = False
        for i in range(6):

            if i % 2 == 0:
                dice.move('S')
            else:
                dice.move('E')

            if dice.top() == self.top():
                for _ in range(4):
                    dice.spin_horizontally()
                    if dice.front() == self.front():
                        break

            if dice.faces == self.faces:
                flg = True
                break
        return flg

n = int(input())
faces = list(map(int, input().split()))
dice_a = Dice(faces[0], faces[1], faces[2], faces[3], faces[4], faces[5])
ans = 'Yes'
for i in range(n - 1):
    faces = list(map(int, input().split()))
    dice_b = Dice(faces[0], faces[1], faces[2], faces[3], faces[4], faces[5])
    if dice_a.equals(dice_b):
        ans = 'No'
        break

print(ans)

Submission status: Accepted

Solution code:
import itertools
import sys

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

rng = range(n)
rq = "NNNNWNNNNWNNNNWNNNNSNNNNWNNNNWNNNNWNNNNSNNNNWNNNNWNNNNWNNNNSNNNNWNNNNWNNNNWNNNN"

for x, y in itertools.combinations(rng,2):
    t = a[x]
    d = a[y]
    for i in rq:
        if i == "E":
          d[0], d[2], d[3], d[5] = d[3], d[0], d[5], d[2]
        elif i == "N":
          d[0], d[1], d[4], d[5] = d[1], d[5], d[0], d[4]
        elif i == "S":
          d[0], d[1], d[4], d[5] = d[4], d[0], d[5], d[1]
        elif i == "W":
          d[0], d[2], d[3], d[5] = d[2], d[5], d[0], d[3]
    
        if t == d:
          print("No")
          sys.exit()

print("Yes")