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:
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 = True
    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 = True
    if h:
        continue
    else:
        h=False
        break
if h:
    print("Yes")
else:
    print("No")

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())
dice=[]
h=False
for i in range(q):
    abz = Dice(list(map(int,input().split())))
    dice.append(abz)
for num in range(q-1):
    dice1 = dice[num]
    for num2 in range(num+1, q):
        dice2 = dice[num2]

        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 = True
        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 = True
        if h:
            break

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

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())
dice=[]
h=False
for i in range(q):
    abz = Dice(list(map(int,input().split())))
    dice.append(abz)
for num in range(q-1):
    dice1 = dice[num]
    for num2 in range(num+1, q):
        dice2 = dice[num2]

        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 = True
        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 = True

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

Submission status: Wrong Answer

Solution code:
def North(dice):
    w = dice[0]
    dice[0] = dice[1]
    dice[1] = dice[5]
    dice[5] = dice[4]
    dice[4] = w
    return dice
def East(dice):
    w = dice[1]
    dice[1] = dice[2]
    dice[2] = dice[4]
    dice[4] = dice[3]
    dice[3] = w
    return dice

def West(dice):
    w = dice[0]
    dice[0] = dice[2]
    dice[2] = dice[5]
    dice[5] = dice[3]
    dice[3] = w
    return dice

maxloop = 4
Ncnt = 0
Ecnt = 0
Wcnt = 0

n = int(input())
Dice = [['' for i2 in range(6)] for i1 in range(n)]
for i in range(n):
    Dice[i] = input().split()

Flag = False
Nloop = True
Eloop = True
Wloop = True

for i in range(n - 1):
    for j in range(i + 1, n):
        while Eloop:
            while Nloop:
                while Wloop:
                    if Dice[i] == Dice[j]:
                        Flag = True
                        Nloop = False
                        Eloop = False
                        Wloop = False
                        break
                    Dice[i] = West(Dice[i])
                    Wcnt += 1
                    if Wcnt == maxloop:
                        Wloop = False
                Dice[i] = North(Dice[i])
                Wcnt = 0
                Wloop = True
                Ncnt += 1
                if Ncnt == maxloop:
                    Nloop = False
            Dice[i] = East(Dice[i])
            Ncnt = 0
            Nloop = True
            Ecnt += 1
            if Ecnt == maxloop:
                Eloop = False

if Flag == False:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
class Checker:
    d = {
        1: { 2: (3,4,5,6), 3: (5,2,4,6), 4: (2,5,3,6), 5: (4,3,2,6) },
        2: { 1: (4,3,6,5), 3: (1,6,4,5), 4: (6,1,3,5), 6: (3,4,1,5) },
        3: { 1: (2,5,6,4), 2: (6,1,5,4), 5: (1,6,2,4), 6: (5,2,1,4) },
        4: { 1: (5,2,6,3), 2: (1,6,5,3), 5: (6,1,2,3), 6: (2,5,1,3) },
        5: { 1: (3,4,6,2), 3: (6,1,4,2), 4: (1,6,3,2), 6: (4,3,1,2) },
        6: { 2: (4,3,5,1), 3: (2,5,4,1), 4: (5,2,3,1), 5: (3,4,2,1) }
        }

    def __init__(self, s):
        l = s.split()
        self.tbl = dict(zip(l, range(1,7)))
        self.pip = dict(zip(range(1,7), l))

    def __call__(self, s):
        l = s.split()
        if self.tbl[l[1]] in self.d[self.tbl[l[0]]]:
            for i,j in zip(self.d[self.tbl[l[0]]][self.tbl[l[1]]], range(2,6)):
                if self.pip[i] != l[j]:
                    return False
            return True
        else:
            return False

def g():
    n = int(input()) - 1
    c = Checker(input())
    for _ in range(n):
        yield c(input())

if any(g()):
    print("No")
else:
    print("Yes")

Submission status: Wrong Answer

Solution code:
class Dice3():

    def __init__(self, v): # v [Top, Front, Right, Left, Back, Bottom ]
        self.view = v
        self.dTFRstr = {}
        for i, j, k in ((ii, (ii++2)%6, (ii+4)%6) for ii in  range(6)):
            self.dTFRstr[self.view[i]]=''.join([self.view[v] for v in (j, k, 5-j, 5-k, j)])

some_same = False
dices = [input().split() for n in range(int(input()))]
for i, d in enumerate(dices[:-1]):
    D1 = Dice3(d)
    for D2 in dices[i+1:]:
        if ''.join(D2[1:3]) in D1.dTFRstr[D2[0]]:
            some_same = True
            break
    if some_same:
        break
if some_same:
    print('No')
else:
    print('Yes')

Submission status: Wrong Answer

Solution code:
class Dice3():

    def __init__(self, v): # v [Top, Front, Right, Left, Back, Bottom ]
        self.view = v
        self.dTFRstr = {}
        for i, j, k in ((ii, (ii++2)%6, (ii+4)%6) for ii in  range(6)):
            self.dTFRstr[self.view[i]]=''.join([self.view[v] for v in (j, k, 5-j, 5-k, j)])

some_same = False
dices = [input().split() for n in range(int(input()))]
for i, d in enumerate(dices[:-1]):
    D1, D1set = Dice3(d), set(d)
    for D2 in dices[i+1:]:
        if set(D2) == D1set and ''.join(D2[1:3]) in D1.dTFRstr[D2[0]]:
            some_same = True
            break
    if some_same:
        break
if some_same:
    print('No')
else:
    print('Yes')

Submission status: Wrong Answer

Solution code:
class Dice3():

    def __init__(self, v): # v [Top, Front, Right, Left, Back, Bottom ]
        self.view = v
        self.dTFRstr = {}
        for i, j, k in ((ii, (ii++2)%6, (ii+4)%6) for ii in  range(6)):
            self.dTFRstr[self.view[i]]=''.join([self.view[v] for v in (j, k, 5-j, 5-k, j)])

some_same = False
dices = [input().split() for n in range(int(input()))]
for i, D1 in enumerate(dices[:-1]):
    d, dset = Dice3(D1), set(D1)
    for D2 in dices[i+1:]:
        if set(D2) == dset and ''.join(D2[1:3]) in d.dTFRstr[D2[0]]\
            and D1[5-D1.index(D2[0])] == D2[5] and D1[5-D1.index(D2[1])] == D2[4] and D1[5-D1.index(D2[2])] == D2[3]:
            some_same = True
            break
    if some_same:
        break
if some_same:
    print('No')
else:
    print('Yes')

Submission status: Wrong Answer

Solution code:
class Dice:
    def __init__(self):
        self.dice=[1,2,3,4,5,6] # up,front,right,left,back,front
    def set(self,l):
        self.dice=l
    def roll(self, s):
        import copy
        mat=((1,4,3,2),(5,0,1,1),(2,2,0,5),(3,3,5,0),(0,5,4,4),(4,1,2,3))
        l=copy.deepcopy(self.dice)
        if s == 'N': c = 0
        if s == 'S': c = 1
        if s == 'E': c = 2
        if s == 'W': c = 3
        for i in range(6):
            self.dice[i]=l[mat[i][c]]
    def get(self):
        return self.dice

l=[]
for i in range(int(input())):
    l.append(Dice())
    l[i].set(list(map(int,input().split())))

f=False
for i in range(1,len(l)):
    if f: break
    for _ in range(4):
        l[i].roll('N')
        for _ in range(4):
            l[i].roll('W')
            f = f or (l[0].get() == l[i].get())
print('Yes' if not f else 'No')

Submission status: Wrong Answer

Solution code:
class Dice(object):
    
    def __init__(self, line):
        self.top = 1
        self.bottom = 6
        self.south = 2
        self.east = 3
        self.west = 4
        self.north = 5
        self.convert = [int(s) for s in line.split()]
    
    def move(self, direction):
        if 'N' == direction:
            self.top, self.north, self.bottom, self.south = self.south, self.top, self.north, self.bottom
        elif 'S' == direction:
            self.top, self.north, self.bottom, self.south = self.north, self.bottom, self.south, self.top
        elif 'W' == direction:
            self.top, self.east, self.bottom, self.west = self.east, self.bottom, self.west, self.top
        elif 'E' == direction:
            self.top, self.east, self.bottom, self.west = self.west, self.top, self.east, self.bottom
    
    def rv(self, key):
        index_list = {
            'top' : self.top,
            'bottom' : self.bottom,
            'south' : self.south,
            'east' : self.east,
            'west' : self.west,
            'notrh' : self.north
        }
        return self.convert[index_list[key] - 1]
    
    def same(self, dice):
        
        for direction in 'NNNNWNNNN':
            self.move(direction)
            if self.rv('south') == dice.rv('south'):
                break
        
        if self.rv('south') != dice.rv('south') or self.rv('notrh') != dice.rv('notrh'):
            return False
        
        for direction in 'WWWW':
            self.move(direction)
            if self.rv('top') == dice.rv('top'):
                break
        
        if self.rv('top') != dice.rv('top'):
            return False
        if self.rv('bottom') != dice.rv('bottom'):
            return False
        if self.rv('east') != dice.rv('east'):
            return False
        if self.rv('notrh') != dice.rv('notrh'):
            return False
        
        return True
    

count = int(input()) - 1
dice = Dice(input())
result = 'Yes'
for i in range(count):
    line = input()
    if line == 'No':
        continue
    if dice.same(Dice(line)):
        result = 'No'

print(result)

Submission status: Wrong Answer

Solution code:
import itertools
n=int(input())
a=[list(map(int,input().split()))for _ in range(n)]
t=0
for d,e in list(itertools.combinations(a, 2)):
 e[3],e[4]=e[4],e[3]
 for i in range(6):
  m={0:'012345',1:'152304',2:'215043',3:'310542',4:'402351',5:'513240'}[i]
  f=[d[int(j)]for j in m];f[3],f[4]=f[4],f[3]
  if f[0]==e[0]:
   f=f[1:5]*2
   for j in range(4):
    if f[j:j+4]==e[1:5]:t=1;break
print(('No','Yes')[t!=1])

Submission status: Wrong Answer

Solution code:
from itertools import*
n=int(input())
a=[list(map(int,input().split()))for _ in range(n)]
t=0
for d,e in list(combinations(a,2)):
 e[3],e[4]=e[4],e[3]
 for i in range(6):
  m={0:'012345',1:'152304',2:'215043',3:'310542',4:'402351',5:'513240'}[i]
  f=[d[int(j)]for j in m];f[3],f[4]=f[4],f[3]
  if e[0]==f[0]and e[5]==f[5]:
   f=f[1:5]*2
   for j in range(4):
    if f[j:j+4]==e[1:5]:t=1
print(('No','Yes')[t!=1])

Submission status: Wrong Answer

Solution code:
from itertools import*
n=int(input())
a=[list(map(int,input().split()))for _ in range(n)]
t=0
for d,e in list(combinations(a,2)):
 e[3],e[4]=e[4],e[3]
 for i in range(6):
  m={0:'012345',1:'152304',2:'215043',3:'310542',4:'402351',5:'513240'}[i]
  f=[d[int(j)]for j in m]
  if f[0]==e[0]and f[5]==e[5]:
   print(f,e)
   f=f[1:5]*2
   for j in range(4):
    if f[j:j+4]==e[1:5]:t=1
print(('Yes','No')[t==1])

Submission status: Wrong Answer

Solution code:
from itertools import*
n=int(input())
a=[list(map(int,input().split()))for _ in range(n)]
for k in range(n):
 b=a[k];b[3],b[4]=b[4],b[3]
t=0
for d,e in list(combinations(a,2)):
 for i in range(6):
  m=('012345','152043','215304','302541','410352','514320')[i]
  f=[d[int(k)]for k in m]
  if f[0]==e[0]and f[5]==e[5]:
   for j in range(4):
    f=f[1:5]*2
    if f[j:j+4]==e[1:5]:t=1
print(('Yes','No')[t==1])

Submission status: Wrong Answer

Solution code:
import random


class Dice(object):
    def __init__(self):
        self.t = 1
        self.s = 2
        self.e = 3
        self.w = 4
        self.n = 5
        self.b = 6

    def __init__(self, faces):
        self.t = faces[0]
        self.s = faces[1]
        self.e = faces[2]
        self.w = faces[3]
        self.n = faces[4]
        self.b = faces[5]

    def roll(self, direct):
        if direct == 0:
            self.t, self.s, self.b, self.n = self.n, self.t, self.s, self.b
        elif direct == 1:
            self.t, self.w, self.b, self.e = self.e, self.t, self.w, self.b
        elif direct == 2:
            self.n, self.w, self.s, self.e = self.w, self.s, self.e, self.n

    def is_equal(self, dice):
        if self.t == dice.t and self.s == dice.s and self.e == dice.e and self.w == dice.w and self.n == dice.n and self.b == dice.b:
            return True
        else:
            return False

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

    if n == 0:
        continue

    dice_a, dice_b = dice_list[0], dice_list[-1]

    for i in range(10000):
        dice_b.roll(random.randint(0, 3))
        if dice_a.is_equal(dice_b):
            break
        if i + 1 == 10000:
            flag = False

    if not flag:
        break

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

Submission status: Wrong Answer

Solution code:
import random


class Dice(object):
    def __init__(self):
        self.t = 1
        self.s = 2
        self.e = 3
        self.w = 4
        self.n = 5
        self.b = 6

    def __init__(self, faces):
        self.t = faces[0]
        self.s = faces[1]
        self.e = faces[2]
        self.w = faces[3]
        self.n = faces[4]
        self.b = faces[5]

    def roll(self, direct):
        if direct == 0:
            self.t, self.s, self.b, self.n = self.n, self.t, self.s, self.b
        elif direct == 1:
            self.t, self.w, self.b, self.e = self.e, self.t, self.w, self.b
        elif direct == 2:
            self.n, self.w, self.s, self.e = self.w, self.s, self.e, self.n

    def is_equal(self, dice):
        if self.t == dice.t and self.s == dice.s and self.e == dice.e and self.w == dice.w and self.n == dice.n and self.b == dice.b:
            return True
        else:
            return False

n = int(input())
dice_list = []
flag_list = []
for _ in range(n):
    flag = False
    faces = list(map(int, input().split()))
    dice_list.append(Dice(faces))

    if n == 0:
        continue

    dice_a, dice_b = dice_list[0], dice_list[-1]

    for i in range(10000):
        dice_b.roll(random.randint(0, 3))
        if dice_a.is_equal(dice_b):
            flag = True
            break

    flag_list.append(flag)

if any(flag_list):
    print('No')
else:
    print('Yes')

Submission status: Wrong Answer

Solution code:
class dice:
    def __init__(self, li = [0] * 6):
        self.men = [0] + li
    def move0(self, a, b, c, d):
        self.men[a], self.men[b], self.men[c], self.men[d] = self.men[b], self.men[c], self.men[d], self.men[a]
    def move(self, h):
        if h == "N":
            self.move0(1, 2, 6, 5)
        elif h == "S":
            self.move0(1, 5, 6, 2)
        elif h == "W":
            self.move0(1, 3, 6, 4)
        elif h == "E":
            self.move0(1, 4, 6, 3)
        elif h == "O":
            self.men[1], self.men[6], self.men[2], self.men[5] = self.men[6], self.men[1], self.men[5], self.men[2]
        elif h == "L":
            self.move0(2, 3, 5, 4)
        elif h == "R":
            self.move0(2, 4, 5, 3)
        elif h == "B":
            self.men[3], self.men[4], self.men[2], self.men[5] = self.men[4], self.men[3], self.men[5], self.men[2]
        else:
            print("▲err")
    def move2(self, a, b):
        if self.men[1] != a:
            for i, s in [(2, "N"), (3, "W"), (4, "E"), (5, "S"), (6, "O")]:
                if self.men[i] == a:
                    self.move(s)
                    break
        if self.men[2] != b:
            if b == self.men[3]:
                self.move("L")
            elif b == self.men[4]:
                self.move("R")
            else:
                self.move("B")
n = int(input())
ans = set()
for _ in range(n):
    li = list(map(int, input().split()))
    for i in range(6):
        saikoro3 = dice(li)
        if i:
            saikoro3.move("_SWENO"[i])
        ans.add(tuple(saikoro3.men))
        for _ in range(3):
            saikoro3.move("L")
            ans.add(tuple(saikoro3.men))
print("Yes" if len(ans) == n * 24 else "No")

Submission status: Wrong Answer

Solution code:
n=int(input())
a=[list(map(int,input().split()))for _ in range(n)]
for k in range(n):
 b=a[k];b[3],b[4]=b[4],b[3]
t=0
for i in range(n-1):
 d=a[i]
 for j in range(i+1,n):
  e=a[j]
  for p in('012345','152043','215304','302541','410352','514320'):
   f=[d[int(k)]for k in p]
   if f[0]==e[0]:
    f=f[1:5]*2
    for k in range(4):
     if f[k:k+4]==e[1:5]:t=1
print(('Yes','No')[t])

Submission status: Wrong Answer

Solution code:
n=int(input())
a=[list(map(int,input().split()))for _ in range(n)]
for k in range(n):
 b=a[k];b[3],b[4]=b[4],b[3]
for i in range(n-1):
 d=a[i]
 for j in range(i+1,n):
  e=a[j]
  for p in('012345','152043','215304','302541','410352','514320'):
   f=[d[int(k)]for k in p]
   if f[0]==e[0]and f[5]==e[5]:
    f=f[1:5]*2
    for k in range(4):
     t=(0,1)[f[k:k+4]==e[1:5]]
print(('Yes','No')[t])

Submission status: Wrong Answer

Solution code:
n=int(input())
a=[list(map(int,input().split()))for _ in range(n)]
for k in range(n):
 b=a[k];b[3],b[4]=b[4],b[3]
t=0
for i in range(n-1):
 d=a[i]
 for j in range(i+1,n):
  e=a[j]
  for p in('012345','152043','215304','302541','410352'):
   f=[d[int(k)]for k in p]
   if f[0]==e[0]and f[5]==e[5]:
    f=f[1:5]*2
    for k in range(4):
     if f[k:k+4]==e[1:5]:t=1
print(('Yes','No')[t])

Submission status: Wrong Answer

Solution code:
import sys
n=int(input())
a=[list(map(int,input().split()))for _ in range(n)]
for i in range(n-1):
 d=a[i];d[3],d[4]=d[4],d[3]
 for j in range(i+1,n):
  e=a[j];e[3],e[4]=e[4],e[3]
  for p in('012345','152043','215304','302541','410352','514320'):
   f=[d[int(k)]for k in p]
   if f[0]==e[0]and f[5]==e[5]:
    f=f[1:5]*2
    for k in range(4):
     if f[k:k+4]==e[1:5]:print('No');sys.exit()
print('Yes')

Submission status: Wrong Answer

Solution code:
from itertools import*
n=int(input())
a=[list(map(int,input().split()))for _ in range(n)]
def f():
 for d,e in list(combinations(a,2)):
  d[3],d[4]=d[4],d[3]
  e[3],e[4]=e[4],e[3]
  for p in([0,1,2,3,4,5],[1,5,2,0,4,3],[2,1,5,3,0,4],[3,0,2,5,4,1],[4,1,0,3,5,2],[5,1,4,3,2,0]):
   f=[d[k]for k in p]
   if f[0]==e[0]and f[5]==e[5]:
    f=f[1:5]*2
    for k in range(4):
     if f[k:k+4]==e[1:5]:return'No'
 return'Yes'
print(f())

Submission status: Wrong Answer

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

class Dice(object):
    def __init__(self, line):
        self.sides = { k:v for k,v in zip('tsewnb', [int(s) for s in line.split()])}
        
    def move(self, way):
        s = self.sides
        if 'N' == way:
            s['t'], s['n'], s['b'], s['s'] = s['s'], s['t'], s['n'], s['b']
        elif 'S' == way:
            s['t'], s['n'], s['b'], s['s'] = s['n'], s['b'], s['s'], s['t']
        elif 'W' == way:
            s['t'], s['e'], s['b'], s['w'] = s['e'], s['b'], s['w'], s['t']
        elif 'E' == way:
            s['t'], s['e'], s['b'], s['w'] = s['w'], s['t'], s['e'], s['b']
        
    def same(self, dice):
        for way in 'NNNNW' * 4:
            self.move(way)
            if self.sides == dice.sides:
                return True
        return False
        


count = int(input()) - 1
dice = Dice(input())
result = 'Yes'
for i in range(count):
    line = input()
    if result == 'No':
        continue
    if dice.same(Dice(line)):
        result = 'No'

print(result)

Submission status: Wrong Answer

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

class Dice(object):
    def __init__(self, line):
        self.sides = { k:v for k,v in zip('tsewnb', [int(s) for s in line.split()])}
        
    def move(self, way):
        s = self.sides
        if 'N' == way:
            s['t'], s['n'], s['b'], s['s'] = s['s'], s['t'], s['n'], s['b']
        elif 'S' == way:
            s['t'], s['n'], s['b'], s['s'] = s['n'], s['b'], s['s'], s['t']
        elif 'W' == way:
            s['t'], s['e'], s['b'], s['w'] = s['e'], s['b'], s['w'], s['t']
        elif 'E' == way:
            s['t'], s['e'], s['b'], s['w'] = s['w'], s['t'], s['e'], s['b']
        
    def same(self, dice):
        for way in 'NNNNW' * 5:
            self.move(way)
            if self.sides == dice.sides:
                return True
        return False
        


count = int(input()) - 1
dice = Dice(input())
result = 'Yes'
for i in range(count):
    line = input()
    if result == 'No':
        continue
    if dice.same(Dice(line)):
        result = 'No'

print(result)

Submission status: Wrong Answer

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

class Dice(object):
    def __init__(self, line):
        self.sides = { k:v for k,v in zip('tsewnb', [int(s) for s in line.split()])}
        
    def move(self, way):
        s = self.sides
        if 'N' == way:
            s['t'], s['n'], s['b'], s['s'] = s['s'], s['t'], s['n'], s['b']
        elif 'S' == way:
            s['t'], s['n'], s['b'], s['s'] = s['n'], s['b'], s['s'], s['t']
        elif 'W' == way:
            s['t'], s['e'], s['b'], s['w'] = s['e'], s['b'], s['w'], s['t']
        elif 'E' == way:
            s['t'], s['e'], s['b'], s['w'] = s['w'], s['t'], s['e'], s['b']
        
    def same(self, dice):
        for way in ('NNNNW') * 4 + 'W' + ('NNNNW' * 4):
            self.move(way)
            if self.sides == dice.sides:
                return True
        return False
        


count = int(input()) - 1
dice = Dice(input())
result = 'Yes'
for i in range(count):
    line = input()
    if result == 'No':
        continue
    if dice.same(Dice(line)):
        result = 'No'

print(result)

Submission status: Wrong Answer

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

class Dice(object):
    def __init__(self, line):
        self.sides = { k:v for k,v in zip('tsewnb', [int(s) for s in line.split()])}
        
    def move(self, way):
        s = self.sides
        if 'N' == way:
            s['t'], s['n'], s['b'], s['s'] = s['s'], s['t'], s['n'], s['b']
        elif 'S' == way:
            s['t'], s['n'], s['b'], s['s'] = s['n'], s['b'], s['s'], s['t']
        elif 'W' == way:
            s['t'], s['e'], s['b'], s['w'] = s['e'], s['b'], s['w'], s['t']
        elif 'E' == way:
            s['t'], s['e'], s['b'], s['w'] = s['w'], s['t'], s['e'], s['b']
        
    def same(self, dice):
        for way in ('NNNNW') * 4 + 'W' + ('NNNNW' * 4):
            self.move(way)
            if self.sides == dice.sides:
                return True
        return False
        


count = int(input()) - 1
dice = Dice(input())
result = 'Yes'
for i in range(count):
    line = input()
    if result == 'No':
        continue
    if dice.same(Dice(line)):
        result = 'No'

print(result)

Submission status: Wrong Answer

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

class Dice(object):
    def __init__(self, line):
        self.sides = { k:v for k,v in zip('tsewnb', [int(s) for s in line.split()])}
        
    def move(self, way):
        s = self.sides
        if 'N' == way:
            s['t'], s['n'], s['b'], s['s'] = s['s'], s['t'], s['n'], s['b']
        elif 'S' == way:
            s['t'], s['n'], s['b'], s['s'] = s['n'], s['b'], s['s'], s['t']
        elif 'W' == way:
            s['t'], s['e'], s['b'], s['w'] = s['e'], s['b'], s['w'], s['t']
        elif 'E' == way:
            s['t'], s['e'], s['b'], s['w'] = s['w'], s['t'], s['e'], s['b']
        
    def same(self, dice):
        for way in 'NNNNWNNNNWNNNNWNNNNWWNNNNWNNNNWNNNNWNNNNW':
            self.move(way)
            if self.sides == dice.sides:
                return True
        return False
        


count = int(input()) - 1
dice = Dice(input())
result = 'Yes'
for i in range(count):
    line = input()
    if result == 'No':
        continue
    if dice.same(Dice(line)):
        result = 'No'

print(result)

Submission status: Wrong Answer

Solution code:
class Dice(object):
    def __init__(self, line):
        self.sides = { k:v for k,v in zip('tsewnb', [int(s) for s in line.split()])}
        
    def move(self, way):
        s = self.sides
        if 'N' == way:
            s['t'], s['n'], s['b'], s['s'] = s['s'], s['t'], s['n'], s['b']
        elif 'S' == way:
            s['t'], s['n'], s['b'], s['s'] = s['n'], s['b'], s['s'], s['t']
        elif 'W' == way:
            s['t'], s['e'], s['b'], s['w'] = s['e'], s['b'], s['w'], s['t']
        elif 'E' == way:
            s['t'], s['e'], s['b'], s['w'] = s['w'], s['t'], s['e'], s['b']
        
    def same(self, dice):
        for way in 'NNNNWNNNNWNNNNWNNNNWWNNNNWNNNNWNNNNWNNNNW':
            self.move(way)
            if self.sides == dice.sides:
                return True
        return False
        


count = int(raw_input()) - 1
dice = Dice(raw_input())
result = 'Yes'
for i in range(count):
    line = raw_input()
    if result == 'No':
        continue
    if dice.same(Dice(line)):
        result = 'No'

print(result)

Submission status: Wrong Answer

Solution code:
import random
class Dice:
    def __init__(self, num_list):
        self.top = num_list[0]
        self.dside = num_list[1]
        self.rside = num_list[2]
        self.lside = num_list[3]
        self.uside = num_list[4]
        self.bottom = num_list[5]
        self.dlist = num_list
    def north(self):
        (self.top, self.dside, self.bottom, self.uside) = (self.dside, 
            self.bottom, self.uside, self.top)
    def east(self):
        (self.top, self.lside, self.bottom, self.rside) = (self.lside,
            self.bottom, self.rside, self.top)
    def south(self):
        (self.top, self.dside, self.bottom, self.uside) = (self.uside, 
            self.top, self.dside, self.bottom)

n = int(input())
num = [list(map(int, input().split())) for i in range(n)]
dice = [Dice(num[i]) for i in range(n)]
for idx1, i in enumerate(dice):
    for idx2, j in enumerate(dice):
        if idx2 <= idx1:
            continue
        elif len(set(i.dlist)^set(j.dlist)):
            print("No")
            break
        elif len(set(num[0])) < 4:
            while(i.top != j.top or i.rside != j.rside
                  or i.dside != j.dside):
                mode = random.randint(0, 2)
                if mode == 0:
                    j.north()
                elif mode == 1:
                    j.east()
                else:
                    j.south()
        else:
            while(i.top != j.top or 
                 (i.rside != j.rside and i.uside != j.uside)):
                mode = random.randint(0, 2)
                if mode == 0:
                    j.north()
                elif mode == 1:
                    j.east()
                elif mode == 2:
                    j.south()
        if (i.bottom == j.bottom and i.lside == j.lside 
            and i.dside == j.dside):
            print("No")
            break
    else:
        continue
    break
else:
    print("Yes")