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: Wrong Answer

Solution code:
n=int(input())

class dice(object):
	def __init__(self, d):
		self.d = d

	def roll(self,com):
		a1,a2,a3,a4,a5,a6=self.d
		if com=="E":
			self.d = [a4,a2,a1,a6,a5,a3]
		elif com=="W":
			self.d = [a3,a2,a6,a1,a5,a4]
		elif com=="S":
			self.d = [a5,a1,a3,a4,a6,a2]
		elif com=="N":
			self.d = [a2,a6,a3,a4,a1,a5]

import random
ds=[]
for i in range(n):
	ds.append(dice(list(map(int,input().split()))))
flag="Yes"
for i in range(n):
	for j in range(i):
		if sorted(ds[i].d)!=sorted(ds[j].d):
			flag="No"
		else:
			c=["E","W","S","N"]
			n=0
			while n<1000:
				if ds[i].d==ds[j].d:
					break 
				else:
					ds[i].roll(c[random.randint(1,2)])
				n+=1
			if n==1000:
				pass
			else:
				flag="No"

print(flag)

Submission status: Wrong Answer

Solution code:
class Dice:
    def __init__(self, init_values = ['1','2','3','4','5','6']):
        self.value = dict(zip(["top", "front","right","left","back","bottom"]\
                             , init_values))

    #north, south, east and west
    def roll(self, direction):
        if direction == 'N':
            self.value["top"], self.value["front"], self.value["bottom"], self.value["back"] = \
            self.value["front"], self.value["bottom"], self.value["back"], self.value["top"]
        elif direction == 'S':
            self.value["top"], self.value["back"], self.value["bottom"], self.value["front"] = \
            self.value["back"], self.value["bottom"], self.value["front"], self.value["top"]
        elif direction == 'E':
            self.value["top"], self.value["left"], self.value["bottom"], self.value["right"] = \
            self.value["left"], self.value["bottom"], self.value["right"], self.value["top"]
        elif direction == 'W':
            self.value["top"], self.value["right"], self.value["bottom"], self.value["left"] = \
            self.value["right"], self.value["bottom"], self.value["left"], self.value["top"]
        else:
            print("Error: illegal format.")

    # clockwise, counterclockwise
    def spin(self, direction):
        if direction == "CW":
            self.value["front"], self.value["right"], self.value["back"], self.value["left"] = \
            self.value["right"], self.value["back"], self.value["left"], self.value["front"]
        elif direction == "CCW":
            self.value["front"], self.value["left"], self.value["back"], self.value["right"] = \
            self.value["left"], self.value["back"], self.value["right"], self.value["front"]
        else:
            print("Error: illegal format.")

    def is_same(self, other_dice):
        for direction in 'SESESE':
            other_dice.roll(direction)
            if self.value["top"] == other_dice.value["top"]:
                for j in range(4):
                    other_dice.spin("CW")
                    if self.value == other_dice.value:
                        return True
        return False

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

result = "Yes"
for i in range(len(dice_arr)-1):
    for j in range(i+1,len(dice_arr)):
        if dice_arr[i].is_same(dice_arr[j]):
            result = "No"
            print(i, j, "\n", dice_arr[i].value, "\n", dice_arr[j].value)
            break
    if result == "No":
        break

print(result)

Submission status: Wrong Answer

Solution code:
def move(d, r):
    if r == 'N':
        return (d[1], d[5], d[2], d[3], d[0], d[4])
    if r == 'E':
        return (d[3], d[1], d[0], d[5], d[4], d[2])
    if r == 'W':
        return (d[2], d[1], d[5], d[0], d[4], d[3])
    if r == 'S':
        return (d[4], d[0], d[2], d[3], d[5], d[1])
    return d
     
def gen_all(dice_1):
    dice = {dice_1}
    while True:
        dice2 = {move(d,r) for d in dice for r in list("NEWS")}.union(dice)
        if dice == dice2: break
        dice = dice2
    return dice    


n = int(input())
count = 0
dice = [0 for i in range(n)]


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

for i in range(n):
    for k in range(i):
        if dice[i] in gen_all(dice[k]):
            print("No")
            count = 1
            break
if count == 0:
    print("Yes")

Submission status: Wrong Answer

Solution code:
n = int(input())

def rot(dice,rotation):
    if rotation == "E":
        dice = (dice[3],dice[1],dice[0],dice[5],dice[4],dice[2])
    elif rotation == "W":
        dice = (dice[2],dice[1],dice[5],dice[0],dice[4],dice[3])
    elif rotation == "N":
        dice = (dice[1],dice[5],dice[2],dice[3],dice[0],dice[4])
    elif rotation == "S":
        dice = (dice[4],dice[0],dice[2],dice[3],dice[5],dice[1])
    return dice

def make_all_pattern(dice):
    pattern = {dice}
    pattern2 = pattern
    while True:
        pattern2 = pattern.union({rot(d,r) for d in pattern for r in list("NEWS")})
        if pattern2 == pattern:
            break
        pattern = pattern2
    return pattern

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

for j in range(1):
    if n > 24:
        print("No")
        break
    pattern = set()
    for i in range(n-1):
        pattern = pattern.union(make_all_pattern(dice[i]))
        if dice[i+1] in pattern:
            print("No")
            break
    else:
        print("Yes")

Submission status: Wrong Answer

Solution code:
n = int(input())

def rot(dice,rotation):
    if rotation == "E":
        dice = (dice[3],dice[1],dice[0],dice[5],dice[4],dice[2])
    elif rotation == "W":
        dice = (dice[2],dice[1],dice[5],dice[0],dice[4],dice[3])
    elif rotation == "N":
        dice = (dice[1],dice[5],dice[2],dice[3],dice[0],dice[4])
    elif rotation == "S":
        dice = (dice[4],dice[0],dice[2],dice[3],dice[5],dice[1])
    return dice

def make_all_pattern(dice):
    pattern = {dice}
    pattern2 = pattern
    while True:
        pattern2 = pattern.union({rot(d,r) for d in pattern for r in list("NEWS")})
        if pattern2 == pattern:
            break
        pattern = pattern2
    return pattern

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

for j in range(1):
    if n > 24:
        print("No")
        break
    pattern = set()
    for i in range(n-1):
        pattern = pattern.union(make_all_pattern(dice[i]))
        if dice[i] in pattern:
            print("No")
            break
    else:
        print("Yes")

Submission status: Wrong Answer

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())
ans = "Yes"
ds =[]

for i in range(n):
    ds.append(dice(list(map(int,input().split()))))

for i in range(len(ds)-1):
    for j in range(i+1,len(ds)):
        d_tmp = dice(ds[j].pip)
        for op in "EEENEEENEEESEEESEEENEEEN":
            if ds[i].pip == d_tmp.pip:
                ans = "No"
                break

print(ans)

Submission status: Wrong Answer

Solution code:
import sys
import copy
n = int(input())
inp = [[i for i in input().split()] for i in range(n)]
a = copy.copy(inp)
number = 3
count = 0
yoshi = 33
kais = n-1
for i in range(n-3):
    number += 3+i
for i in range(number):
    if i == kais-1:
        for i3 in range(n-1):
            if i3 == 0:
                sika = kais
                continue
            kais += n-i3
            if i >= sika and i < kais:
                sika = kais
                count = i3
if n >=100:
    yoshi =21
    for i2 in range(1,yoshi):
        if (i2<=20 and i2%5==0) or i2==22 or i2==27 or i2==28:
            s = "N"
        else:
            s = "E"
        if s == "E":
            for i4 in range(len(inp)):
                if i4 == count:
                    continue
                b = []
                append = b.append
                append(a[i4][3])
                append(a[i4][1])
                append(a[i4][0])
                append(a[i4][5])
                append(a[i4][4])
                append(a[i4][2])
                a[i4][:] = b[:]
            for x in range(len(inp)):
                if x == count:
                    continue
                else:
                    if inp[count][:] == a[x][:]:
                        print("No")
                        sys.exit()
        elif s == "N":
            for i4 in range(len(inp)):
                if i4 == count:
                    continue
                b = []
                append = b.append
                append(a[i4][1])
                append(a[i4][5])
                append(a[i4][2])
                append(a[i4][3])
                append(a[i4][0])
                append(a[i4][4])
                a[i4][:] = b[:]
            for x in range(len(inp)):
                if x == count:
                    continue
                else:
                    if inp[count][:] == a[x][:]:
                        print("No")
                        sys.exit()
print("Yes")

Submission status: Wrong Answer

Solution code:
import sys
import copy
n = int(input())
inp = [[i for i in input().split()] for i in range(n)]
a = copy.copy(inp)
number = 3
count = 0
yoshi = 33
kais = n-1
for i in range(n-3):
    number += 3+i
if n>=100:
    yoshi =5
for i in range(number):
    if i == kais-1:
        for i3 in range(n-1):
            if i3 == 0:
                sika = kais
                continue
            kais += n-i3
            if i >= sika and i < kais:
                sika = kais
                count = i3
    for i2 in range(1,yoshi):
        if (i2<=20 and i2%5==0) or i2==22 or i2==27 or i2==28:
            s = "N"
        else:
            s = "E"
        if s == "E":
            for i4 in range(len(inp)):
                if i4 == count:
                    continue
                b = []
                append = b.append
                append(a[i4][3])
                append(a[i4][1])
                append(a[i4][0])
                append(a[i4][5])
                append(a[i4][4])
                append(a[i4][2])
                a[i4][:] = b[:]
            for x in range(len(inp)):
                if x == count:
                    continue
                else:
                    if inp[count][:] == a[x][:]:
                        print("No")
                        sys.exit()
        elif s == "N":
            for i4 in range(len(inp)):
                if i4 == count:
                    continue
                b = []
                append = b.append
                append(a[i4][1])
                append(a[i4][5])
                append(a[i4][2])
                append(a[i4][3])
                append(a[i4][0])
                append(a[i4][4])
                a[i4][:] = b[:]
            for x in range(len(inp)):
                if x == count:
                    continue
                else:
                    if inp[count][:] == a[x][:]:
                        print("No")
                        sys.exit()
print("Yes")

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

import sys
import os
import math


N = int(input())
dices = []
for i in range(N):
    dice = list(map(int, input().split()))
    dices.append(dice)

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


def check(dice0, dice1):

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

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

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


def check2(dice0, dice1):
    result = check(dice0, dice1)
    if result:
        return True
    else:
        # ????????????
        dice0 = dice_roll(dice0, 'N')
        result = check(dice0, dice1)
        if result:
            return True
        else:
            return False


for i in range(N):
    for j in range(i+1, N):
        is_same = check2(dices[i], dices[j])
        if is_same:
            print('No')
            quit()
print('Yes')

Submission status: Wrong Answer

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

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

dice_set=[]
dice_same=0
dice_not_same=0


for l in range(int(input())):
    dice_set.append(list(map(int,input().split())))

for m in range(len(dice_set)):
    dice_list=[]


    label = dice_set[m]
    rotation = dice(label)
    for i in range(3):
        dice_list.append(rotation.output())
        for j in range(3):
            rotation.roll("E")
            dice_list.append(rotation.output())
        rotation.roll("N")

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

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


    for n in range(m+1,len(dice_set)):
        if dice_set[m+1] in dice_list:
            dice_same += 1

if dice_same == 0:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

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

    def issame(self, s):
        answer = 0
        for _ in range(3):
            for _ in range(4):
                self.roll("N")
                self.roll("E")
                self.roll("S")
                if self.s == s:
                    answer = 1
            self.roll("N")
            for _ in range(4):
                self.roll("N")
                self.roll("E")
                self.roll("S")
                if self.s == s:
                    answer = 1
            self.roll("E")
        return answer


n = int(input())
for i in range(n):
    s = list(map(int, input().split()))
    code = "dice{} = Dice(s)".format(i)
    exec(code)

answer = "Yes"
for i in range(n-2):
    for j in range(i+1, n-1):
        code = "ans = dice{0}.issame(dice{1}.s)".format(i, j)
        exec(code)
        if ans == 1:
            answer = "No"

print(answer)

Submission status: Wrong Answer

Solution code:
n = int(input())
x = [[] for i in range(n)]
for i in range(n):
    x[i] = list(map(int, input().split()))
z = [[0, 1, 2, 3], [0, 2, 1, 1], [1, 0, 2, 1], [2, 0, 1, 0], [1, 2, 0, 0], [2, 1, 0, 1]]

def compare(x, y):
    succeed = False
    for i in range(6):
        match = True
        order = [0, 0, 0]
        for j in range(3):
            if {x[j], x[-j-1]} != {y[z[i][j]], y[-z[i][j]-1]}:
                match = False
                break
            if x[j] == y[z[i][j]]:
                order[j] = 1
                if x[j] == x[-j-1]:
                    order[j] = 2
        if match:
            if 2 in order:
                succeed = True
                break
            if (z[i][3] == 0 or z[i][3] == 3) and sum(order) % 2:
                succeed = True
                break
            if z[i][3] == 1 and not sum(order) % 2:
                succeed = True
                break
    if succeed:
        return True
    else:
        return False

different = True
for i in range(n):
    for j in range(i+1, n, 1):
        if compare(x[i], x[j]):
            print(i, j)
            different = False
            break
    if not different:
        break
if different:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

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

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

"""

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

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

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

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

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

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

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

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

# ?????????
d = []
num = int(input().strip())

for i in range(num): # ??????????????????
    tmp = Dice()
    tmp.setDice(list(map(int,input().strip().split())))
    d.append(tmp)

ret = "Yes"

for i in range(num-1):
    for j in range(i + 1,num):
        v1 = d[i].Search(d[i].side[Dice.T], d[i].side[Dice.S], Dice.E)
        v2 = d[j].Search(d[i].side[Dice.T], d[i].side[Dice.S], Dice.E)
#        print("{0}/{1} V1={2} V2={3}".format(i,j,v1,v2))
        if v1 == v2:
            ret = "No"
            break
    if ret == "No":
        break

print(ret)

Submission status: Wrong Answer

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

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

"""

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

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

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

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

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

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

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

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

# ?????????
d = []
num = int(input().strip())

for i in range(num): # ??????????????????
    tmp = Dice()
    tmp.setDice(list(map(int,input().strip().split())))
    d.append(tmp)

ret = "Yes"

for i in range(num-1):
    for j in range(i + 1,num):
        # ??????????????¢?????°???????????????????¢??????????
        s1 = set(d[i].side)
        s2 = set(d[j].side)
        if (s1 ^ s2): # ??????????????????
            break;
        v1 = d[i].Search(d[i].side[Dice.T], d[i].side[Dice.S], Dice.E)
        v2 = d[j].Search(d[i].side[Dice.T], d[i].side[Dice.S], Dice.E)
        print("{0}/{1} V1={2} V2={3}".format(i,j,v1,v2))
        if v1 == v2:
            ret = "No"
            break
        if ret == "No":
            break

print(ret)

Submission status: Wrong Answer

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

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

"""

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

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

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

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

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

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

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

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

# ?????????
d = []
num = int(input().strip())

for i in range(num): # ??????????????????
    tmp = Dice()
    tmp.setDice(list(map(int,input().strip().split())))
    d.append(tmp)

ret = "Yes"

for i in range(num-1):
    for j in range(i + 1,num):
        # ??????????????¢?????°???????????????????¢??????????
        s1 = set(d[i].side)
        s2 = set(d[j].side)
        if (s1 ^ s2): # ??????????????????
            break;
        v1 = d[i].Search(d[i].side[Dice.T], d[i].side[Dice.S], Dice.E)
        v2 = d[j].Search(d[i].side[Dice.T], d[i].side[Dice.S], Dice.E)
#        print("{0}/{1} V1={2} V2={3}".format(i,j,v1,v2))
        if v1 == v2:
            ret = "No"
            break
        if ret == "No":
            break

print(ret)

Submission status: Wrong Answer

Solution code:
class Dice():
    def __init__(self,ary):
        self.top = ary[0]
        self.south = ary[1]
        self.east = ary[2]
        self.west = ary[3]
        self.north = ary[4]
        self.bottom = ary[5]

    def get_top(self):
        return self.top

    def rotate_north(self):
        self.top,self.south,self.north,self.bottom = self.south,self.bottom,self.top,self.north
    
    def rotate_south(self):
        self.top,self.south,self.north,self.bottom = self.north,self.top,self.bottom,self.south

    def rotate_west(self):
        self.top,self.west,self.bottom,self.east = self.east,self.top,self.west,self.bottom

    def rotate_east(self):
        self.top,self.west,self.bottom,self.east = self.west,self.bottom,self.east,self.top

    def rotate_horizon(self):
        self.south,self.east,self.north,self.west = self.west,self.south,self.east,self.north

    def get_east(self):
        return self.east

q = int(input())
dice1 = Dice(list(map(int,input().split())))
for i in range(q-1):
    dice2 = Dice(list(map(int,input().split())))
    h=""

    for i in range(4):
        dice2.rotate_west()
        if dice1.top == dice2.top:
            for _ in range(4):
                dice2.rotate_horizon()
                if dice1.south == dice2.south:
                    if dice1.east == dice2.east and dice1.west == dice2.west:
                        h = "Yes"
    for _ in range(4):
        dice2.rotate_north()
        if dice1.top == dice2.top:
            for m in range(4):
                dice2.rotate_horizon()
                if dice1.south == dice2.south:
                    if dice1.east == dice2.east and dice1.west == dice2.west:
                        h = "Yes"
    if h:
        continue
    else:
        h="No"
        break
print(h)