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, data):
        self.data = data

    def __eq__(self, value):

            
        for i in range(4):
            if self.data[0] == value.data[0]:
                for j in range(4):
                    if self.data == value.data:
                        return True
                    self.move('R')
            self.move('E')

        for i in range(4):
            if self.data[0] == value.data[0]:
                for j in range(4):
                    if self.data == value.data:
                        return True
                    self.move('R')
            self.move('N')
        return False

    def move(self, direction):
        if direction == 'E':
            self.data[0],self.data[3], self.data[5], self.data[2] = \
                self.data[3],self.data[5], self.data[2], self.data[0] 
        elif direction == 'N':
            self.data[0],self.data[1], self.data[5], self.data[4] = \
                self.data[1],self.data[5], self.data[4], self.data[0]
        elif direction == 'S':
            self.data[0],self.data[1], self.data[5], self.data[4] = \
                self.data[4],self.data[0], self.data[1], self.data[5]
        elif direction == 'W':
            self.data[0],self.data[2], self.data[5], self.data[3] = \
                self.data[2],self.data[5], self.data[3], self.data[0]
        elif direction == 'R':
            self.data[1],self.data[2], self.data[4], self.data[3] = \
                self.data[2],self.data[4], self.data[3], self.data[1]

a = []
for i in range(int(input())):
    a += [Dice(input().split())]

p = 'Yes'
for i in range(len(a) - 1):
    for j in range(i,len(a)):
        if a[i] == a[j]:
            p = 'No'
            break
print(p)

Submission status: Wrong Answer

Solution code:
class Dice:
    def __init__(self, data):
        self.data = data
    
    def __eq__(self, value):
        for a in range(0,6,5):
            self.moveTopTo(self.getSortedList()[a])
            value.moveTopTo(value.getSortedList()[a])
            for b in range(4):
                if self.data == value.data:
                    return True
                else:
                    value.move('R')
        return False
    
    def move(self, direction):
        if direction == 'E':
            self.data[0], self.data[3], self.data[5], self.data[2] = \
                self.data[3], self.data[5], self.data[2], self.data[0]
        elif direction == 'N':
            self.data[0], self.data[4], self.data[5], self.data[1] = \
                self.data[1], self.data[0], self.data[4], self.data[5]
        elif direction == 'S':
            self.data[0], self.data[1], self.data[5], self.data[4] = \
                self.data[4], self.data[0], self.data[1], self.data[5]
        elif direction == 'W':
            self.data[0], self.data[2], self.data[5], self.data[3] = \
                self.data[2], self.data[5], self.data[3], self.data[0]
        elif direction == 'R':
            self.data[1], self.data[2], self.data[4], self.data[3] = \
                self.data[3], self.data[1], self.data[2], self.data[4]
        elif direction == 'L':
            self.data[1], self.data[2], self.data[4], self.data[3] = \
                self.data[2], self.data[4], self.data[3], self.data[1]

    def moveTopTo(self, target):
        for a in range(4):
            if self.data[0] == target:
                break
            self.move('W')
        if self.data[4] == target:
            self.move('S')
        elif self.data[1] == target:
            self.move('N')
    
    def moveFrontTo(self, target):
        for a in range(4):
            if self.data[1] == target:
                break
            self.move('R')

    def getTop(self):
        return self.data[0]
    
    def getRight(self):
        return self.data[2]

    def getSortedList(self):
        tmp = self.data[:]
        tmp.sort()
        return tmp


dices = []

for a in range(int(input())):
    dices.append(Dice(input().split()))

duplicated = False
for a in range(len(dices) - 1):
    if dices[a] == dices[a + 1]:
        duplicated = True

if not duplicated:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sun Feb 22 11:38:11 2015

@author: hirose
"""

# -*- coding: utf-8 -*-

from random import *
import copy

def command(hougaku, label):
    temp = {}
    temp = copy.deepcopy(label)
    if(hougaku == 'E'):
        label[1] = temp[4]
        label[3] = temp[1]
        label[4] = temp[6]
        label[6] = temp[3]
    elif(hougaku == 'W'):
        label[1] = temp[3]
        label[3] = temp[6]
        label[4] = temp[1]
        label[6] = temp[4]
    elif(hougaku == 'N'):
        label[1] = temp[2]
        label[2] = temp[6]
        label[5] = temp[1]
        label[6] = temp[5]
    elif(hougaku == 'S'):
        label[1] = temp[5]
        label[2] = temp[1]
        label[5] = temp[6]
        label[6] = temp[2]

if __name__=="__main__":
    n = input()
    label = {}
    for i in range(n):
        label[i] = {}
        temp = map(int, raw_input().split())
        for j in range(6):
            label[i][j+1] = temp[j]
        #print label[i]
    count = 0
    flag = 0
    for i in range(n-1):
        for j in range(i+1,n):
            while True:
                if(label[i] == label[j]):
                    flag = 1
                    break
                x = random()
                if(x < 0.25):
                    command('E', label[j])
                elif(x < 0.50):
                    command('W', label[j])
                elif(x < 0.75):
                    command('N', label[j])
                else:
                    command('S', label[j])
                count += 1
                if(count > 1000):
                    break
            if flag == 1:
                break
        if flag == 1:
            break
    if(flag == 0):
        print 'Yes'
    else:
        print 'No'

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sun Feb 22 11:38:11 2015

@author: hirose
"""

# -*- coding: utf-8 -*-

from random import *
import copy

def command(hougaku, label):
    temp = {}
    temp = copy.deepcopy(label)
    if(hougaku == 'E'):
        label[1] = temp[4]
        label[3] = temp[1]
        label[4] = temp[6]
        label[6] = temp[3]
    elif(hougaku == 'W'):
        label[1] = temp[3]
        label[3] = temp[6]
        label[4] = temp[1]
        label[6] = temp[4]
    elif(hougaku == 'N'):
        label[1] = temp[2]
        label[2] = temp[6]
        label[5] = temp[1]
        label[6] = temp[5]
    elif(hougaku == 'S'):
        label[1] = temp[5]
        label[2] = temp[1]
        label[5] = temp[6]
        label[6] = temp[2]

if __name__=="__main__":
    n = input()
    label = {}
    for i in range(n):
        label[i] = {}
        temp = map(int, raw_input().split())
        for j in range(6):
            label[i][j+1] = temp[j]
        #print label[i]
    flag = 0
    for i in range(n-1):
        #print label[i]
        for j in range(i+1,n):
            count = 0
            #print label[j]
            while True:
                if(label[i] == label[j]):
                    flag = 1
                    break
                x = random()
                if(x < 0.25):
                    command('E', label[j])
                elif(x < 0.50):
                    command('W', label[j])
                elif(x < 0.75):
                    command('N', label[j])
                else:
                    command('S', label[j])
                count += 1
                if(count > 30):
                    break
            if flag == 1:
                break
        if flag == 1:
            break
    if(flag == 0):
        print 'Yes'
    else:
        print 'No'

Submission status: Wrong Answer

Solution code:
import sys

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

    def roll_north(self):
        self.__dice = (self.__dice[1], self.__dice[5], self.__dice[2],
                       self.__dice[3], self.__dice[0], self.__dice[4])

    def roll_south(self):
        self.__dice = (self.__dice[4], self.__dice[0], self.__dice[2],
                       self.__dice[3], self.__dice[5], self.__dice[1])

    def roll_west(self):
        self.__dice = (self.__dice[2], self.__dice[1], self.__dice[5],
                       self.__dice[0], self.__dice[4], self.__dice[3])

    def roll_east(self):
        self.__dice = (self.__dice[3], self.__dice[1], self.__dice[0],
                       self.__dice[5], self.__dice[4], self.__dice[2])

    def number(self, face_id):
        return self.__dice[face_id - 1]

    def equals(self, dice):
        my_pair = {self.number(1): self.number(6),
                   self.number(2): self.number(5),
                   self.number(3): self.number(4),
                   self.number(4): self.number(3),
                   self.number(5): self.number(2),
                   self.number(6): self.number(1)}
        other_pair = {dice.number(1): dice.number(6),
                      dice.number(2): dice.number(5),
                      dice.number(3): dice.number(4),
                      dice.number(4): dice.number(3),
                      dice.number(5): dice.number(2),
                      dice.number(6): dice.number(1)}
        if my_pair != other_pair:
            return False
        if self.number(2) in (dice.number(3), dice.number(4)):
            dice.roll_west()
        while self.number(2) != dice.number(2):
            dice.roll_north()
        while self.number(1) != dice.number(1):
            dice.roll_west()
        return self.number(3) == dice.number(3)

n = int(sys.stdin.readline())
dices = []
for i in range(n):
    dices.append(Dice([int(a) for a in sys.stdin.readline().split()]))

for i in range(n):
    for j in range(i + 1, n):
        if dices[i].equals(dices[j]):
            print("No")
            exit(0)
print("Yes")

Submission status: Wrong Answer

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

    def rot(self, d):
        if   d == "N":
            (self.top, self.back, self.bottom, self.front) = (
             self.front, self.top, self.back, self.bottom)
        elif d == "S":
            (self.top, self.back, self.bottom, self.front) = (
             self.back, self.bottom, self.front, self.top)
        elif d == "E":
            (self.top, self.right, self.bottom, self.left) = (
             self.left, self.top, self.right, self.bottom)
        elif d == "W":
            (self.top, self.right, self.bottom, self.left) = (
             self.right, self.bottom, self.left, self.top)

def same(a, b):
    if ((a.top, a.bottom, a.right, a.left, a.front, a.back) ==
        (b.top, b.bottom, b.right, b.left, b.front, b.back)):
        return True
    else:
        return False

N = int(raw_input())
dice = [Dice(map(int, raw_input().split())) for i in xrange(N)]
for i in xrange(N):
    for roll in xrange(100):
        d = "NSEW"[random.randint(0,3)]
        dice[i].rot(d)
        for j in xrange(i + 1, N):
            if same(dice[1], dice[2]):
                print "No"
                exit()
print "No"

Submission status: Wrong Answer

Solution code:
# coding=utf-8
from itertools import combinations


class Dice(object):

    def __init__(self, list_):
        self.label = list_

    def getLabel(self, i):
        return self.label[i - 1]

    def _rotateS(self):
        self.label = [self.getLabel(i) for i in [5, 1, 3, 4, 6, 2]]

    def _rotateN(self):
        self.label = [self.getLabel(i) for i in [2, 6, 3, 4, 1, 5]]

    def _rotateE(self):
        self.label = [self.getLabel(i) for i in [4, 2, 1, 6, 5, 3]]

    def _rotateW(self):
        self.label = [self.getLabel(i) for i in [3, 2, 6, 1, 5, 4]]

    def _spinPos(self):
        self.label = [self.getLabel(i) for i in [1, 4, 2, 5, 3, 6]]

    def _spinNeg(self):
        self.label = [self.getLabel(i) for i in [1, 3, 5, 2, 4, 6]]

    def rotate(self, rotates):
        for r in rotates:
            if r == 'S':
                self._rotateS()
            elif r == 'N':
                self._rotateN()
            elif r == 'E':
                self._rotateE()
            elif r == 'W':
                self._rotateW()
            elif r == 'T':
                self._spinPos()
            elif r == 'B':
                self._spinNeg()

    def matchTopFront(self, top, front):
        try:
            iTop = self.label.index(top) + 1
            topRot = {1: '', 2: 'N', 3: 'W', 4: 'E', 5: 'S', 6: 'SS'}
            self.rotate(topRot[iTop])

            iFront = self.label.index(front) + 1
            frontRot = {2: '', 3: 'B', 4: 'T', 5: 'TT'}
            self.rotate(frontRot[iFront])
            return True
        except KeyError:
            return False

    def copy(self):
        return Dice(self.label[:])

    def _equalWithOverlap(self, other):
        # ?????¢???????????¢?????\????????§6????????????
        for rs in ['', 'S', 'N', 'E', 'W', 'SS']:
            tmp = self.copy()
            for r in rs:
                tmp.rotate(r)
            # ?????¢????????¢????????§??????
            top = tmp.getLabel(1) == other.getLabel(1)
            bottom = tmp.getLabel(6) == other.getLabel(6)
            # ??´??¢?????????????????????????????????????????¢??????????????????????????´??????????????°??????
            # top and bottom ???False??????????????????????????????????????§?????¢??°?????????

            def _side():
                result, n = False, 3
                while not result and n > 0:
                    if tmp.label[1:5] == other.label[1:5]:
                        result = True
                    else:
                        tmp.rotate('T')
                        n -= 1
                return result

            if top and bottom and _side():
                return True
        else:
            return False

    def __eq__(self, other):
        # ????????????????????????????????´?????????????????´???
        if set(self.label) != set(other.label):
            return False
        # ???????????????????????´???
        elif len(self.label) == len(set(self.label)):
                if other.matchTopFront(self.getLabel(1), self.getLabel(2)):
                    return True if self.label == self.label else False
                else:
                    return False
        # ???????????????????????´???
        else:
            d1 = Dice(face1)
            d2 = Dice(face2)
            return True if d1._equalWithOverlap(d2) else False


def main():
    n = input()
    faces = [map(int, raw_input().split()) for _ in xrange(n)]
    for f1, f2 in combinations(faces, 2):
        if f1 == f2 or Dice(f1) == Dice(f2):
            print 'No'
            break
    else:
        print 'Yes'


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
class Dice:

    def __init__(self, faces):
        self.faces = tuple(faces)

    def roll_north(self):
        self.faces = (self.faces[1], self.faces[5], self.faces[2],
                      self.faces[3], self.faces[0], self.faces[4])

    def roll_south(self):
        self.faces = (self.faces[4], self.faces[0], self.faces[2],
                      self.faces[3], self.faces[5], self.faces[1])

    def roll_west(self):
        self.faces = (self.faces[2], self.faces[1], self.faces[5],
                      self.faces[0], self.faces[4], self.faces[3])

    def roll_east(self):
        self.faces = (self.faces[3], self.faces[1], self.faces[0],
                      self.faces[5], self.faces[4], self.faces[2])

    def number(self, face_id):
        return self.faces[face_id - 1]

    def checksame(self, other_dice):
        self_opposite_face = dict(zip([self.number(i) for i in range(1, 7)],
                                      [self.number(i) for i in range(6, 0, -1)]))
        other_opposite_face = dict(zip([other_dice.number(i) for i in range(1, 7)],
                                       [other_dice.number(i) for i in range(6, 0, -1)]))
        if self_opposite_face != other_opposite_face:
            return False
        if self.number(2) in (other_dice.number(3), other_dice.number(4)):
            other_dice.roll_west()
        while self.number(2) != other_dice.number(2):
            other_dice.roll_north()
        while self.number(1) != other_dice.number(1):
            other_dice.roll_west()
        print(self.faces, other_dice.faces)
        return self.number(3) == other_dice.number(3)

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

for i in range(n):
    for j in range(i + 1, n):
        if dice_list[i].checksame(dice_list[j]):
            print("No")
            exit(0)
print("Yes")

Submission status: Wrong Answer

Solution code:
class Dice:

    def __init__(self, faces):
        self.faces = tuple(faces)

    def roll_north(self):
        self.faces = (self.faces[1], self.faces[5], self.faces[2],
                      self.faces[3], self.faces[0], self.faces[4])

    def roll_south(self):
        self.faces = (self.faces[4], self.faces[0], self.faces[2],
                      self.faces[3], self.faces[5], self.faces[1])

    def roll_west(self):
        self.faces = (self.faces[2], self.faces[1], self.faces[5],
                      self.faces[0], self.faces[4], self.faces[3])

    def roll_east(self):
        self.faces = (self.faces[3], self.faces[1], self.faces[0],
                      self.faces[5], self.faces[4], self.faces[2])

    def number(self, face_id):
        return self.faces[face_id - 1]

    def checksame(self, other_dice):
        self_opposite_face = dict(zip([self.number(i) for i in range(1, 7)],
                                      [self.number(i) for i in range(6, 0, -1)]))
        other_opposite_face = dict(zip([other_dice.number(i) for i in range(1, 7)],
                                       [other_dice.number(i) for i in range(6, 0, -1)]))
        if self_opposite_face != other_opposite_face:
            return False
        if self.number(2) in (other_dice.number(3), other_dice.number(4)):
            other_dice.roll_west()
        while self.number(2) != other_dice.number(2):
            other_dice.roll_north()
        while self.number(1) != other_dice.number(1):
            other_dice.roll_west()
        print(self.faces, other_dice.faces)
        return self.number(3) == other_dice.number(3)

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

for i in range(n):
    for j in range(i + 1, n):
        if dice_list[i].checksame(dice_list[j]):
            print("Yes")
            exit(0)
print("No")

Submission status: Wrong Answer

Solution code:
class Dice:

    def __init__(self, faces):
        self.faces = tuple(faces)

    def roll_north(self):
        self.faces = (self.faces[1], self.faces[5], self.faces[2],
                      self.faces[3], self.faces[0], self.faces[4])

    def roll_south(self):
        self.faces = (self.faces[4], self.faces[0], self.faces[2],
                      self.faces[3], self.faces[5], self.faces[1])

    def roll_west(self):
        self.faces = (self.faces[2], self.faces[1], self.faces[5],
                      self.faces[0], self.faces[4], self.faces[3])

    def roll_east(self):
        self.faces = (self.faces[3], self.faces[1], self.faces[0],
                      self.faces[5], self.faces[4], self.faces[2])

    def number(self, face_id):
        return self.faces[face_id - 1]

    def checksame(self, other_dice):
        self_opposite_face = dict(zip([self.number(i) for i in range(1, 7)],
                                      [self.number(i) for i in range(6, 0, -1)]))
        other_opposite_face = dict(zip([other_dice.number(i) for i in range(1, 7)],
                                       [other_dice.number(i) for i in range(6, 0, -1)]))
        if self_opposite_face != other_opposite_face:
            return False
        if self.number(2) in (other_dice.number(3), other_dice.number(4)):
            other_dice.roll_west()
        while self.number(2) != other_dice.number(2):
            other_dice.roll_north()
        while self.number(1) != other_dice.number(1):
            other_dice.roll_west()
        return self.number(3) == other_dice.number(3)

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

for i in range(n):
    for j in range(i + 1, n):
        if dice_list[i].checksame(dice_list[j]):
            print("No")
            exit(0)
print("Yes")

Submission status: Wrong Answer

Solution code:
class Dice:

    def __init__(self, faces):
        self.faces = tuple(faces)

    def roll_north(self):
        self.faces = (self.faces[1], self.faces[5], self.faces[2],
                      self.faces[3], self.faces[0], self.faces[4])

    def roll_south(self):
        self.faces = (self.faces[4], self.faces[0], self.faces[2],
                      self.faces[3], self.faces[5], self.faces[1])

    def roll_west(self):
        self.faces = (self.faces[2], self.faces[1], self.faces[5],
                      self.faces[0], self.faces[4], self.faces[3])

    def roll_east(self):
        self.faces = (self.faces[3], self.faces[1], self.faces[0],
                      self.faces[5], self.faces[4], self.faces[2])

    def rotate(self):
        self.faces = (self.faces[0], self.faces[2], self.faces[4],
                      self.faces[3], self.faces[1], self.faces[5])

    def number(self, face_id):
        return self.faces[face_id - 1]

    def issame(self, other_dice):
        for i in range(4):
            if self.faces[0] == other_dice.faces[0]:
                for j in range(4):
                    if self.faces == other_dice.faces:
                        return True
                    self.rotate()
            self.roll_north()

        for i in range(4):
            if self.faces[0] == other_dice.faces[0]:
                for j in range(4):
                    if self.faces == other_dice.faces:
                        return True
                    self.rotate()
            self.roll_east()
        return False

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

for i in range(n):
    for j in range(i + 1, n):
        if dice_list[i].issame(dice_list[j]):
            print("No")
            exit(0)
print("Yes")

Submission status: Wrong Answer

Solution code:
class Dice:

    def __init__(self, faces):
        self.faces = tuple(faces)

    def roll_north(self):
        self.faces = (self.faces[1], self.faces[5], self.faces[2],
                      self.faces[3], self.faces[0], self.faces[4])

    def roll_south(self):
        self.faces = (self.faces[4], self.faces[0], self.faces[2],
                      self.faces[3], self.faces[5], self.faces[1])

    def roll_west(self):
        self.faces = (self.faces[2], self.faces[1], self.faces[5],
                      self.faces[0], self.faces[4], self.faces[3])

    def roll_east(self):
        self.faces = (self.faces[3], self.faces[1], self.faces[0],
                      self.faces[5], self.faces[4], self.faces[2])

    def rotate(self):
        self.faces = (self.faces[0], self.faces[2], self.faces[4],
                      self.faces[1], self.faces[3], self.faces[5])

    def number(self, face_id):
        return self.faces[face_id - 1]

    def issame(self, other_dice):
        for i in range(4):
            print(self.faces, other_dice.faces)
            if self.faces[0] == other_dice.faces[0]:
                for j in range(4):
                    print(self.faces, other_dice.faces)
                    if self.faces == other_dice.faces:
                        return True
                    self.rotate()
            self.roll_north()

        for i in range(4):
            print(self.faces, other_dice.faces)
            if self.faces[0] == other_dice.faces[0]:
                for j in range(4):
                    print(self.faces, other_dice.faces)
                    if self.faces == other_dice.faces:
                        return True
                    self.rotate()
            self.roll_east()
        return False

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

res = "Yes"
for i in range(n):
    for j in range(i + 1, n):
        if dice_list[i].issame(dice_list[j]):
            res = "No"
            print(res)
            break
print(res)

Submission status: Wrong Answer

Solution code:
class Dice:

    def __init__(self, faces):
        self.faces = tuple(faces)

    def roll_north(self):
        self.faces = (self.faces[1], self.faces[5], self.faces[2],
                      self.faces[3], self.faces[0], self.faces[4])

    def roll_south(self):
        self.faces = (self.faces[4], self.faces[0], self.faces[2],
                      self.faces[3], self.faces[5], self.faces[1])

    def roll_west(self):
        self.faces = (self.faces[2], self.faces[1], self.faces[5],
                      self.faces[0], self.faces[4], self.faces[3])

    def roll_east(self):
        self.faces = (self.faces[3], self.faces[1], self.faces[0],
                      self.faces[5], self.faces[4], self.faces[2])

    def rotate(self):
        self.faces = (self.faces[0], self.faces[2], self.faces[4],
                      self.faces[1], self.faces[3], self.faces[5])

    def number(self, face_id):
        return self.faces[face_id - 1]

    def issame(self, other_dice):
        for i in range(4):
            if self.faces[0] == other_dice.faces[0]:
                for j in range(4):
                    if self.faces == other_dice.faces:
                        return True
                    self.rotate()
            self.roll_north()

        for i in range(4):
            if self.faces[0] == other_dice.faces[0]:
                for j in range(4):
                    if self.faces == other_dice.faces:
                        return True
                    self.rotate()
            self.roll_east()
        return False

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

res = "Yes"
for i in range(n):
    for j in range(i + 1, n):
        if dice_list[i].issame(dice_list[j]):
            res = "No"
            print(res)
            break
print(res)

Submission status: Wrong Answer

Solution code:
import random

class Dice:
  def __init__(self, list = map(str, range(1, 7))):
    self.top = list[0]
    self.front = list[1]
    self.right = list[2]
    self.left = list[3]
    self.back = list[4]
    self.bottom = list[5]

    self.dic = {}
    for i in xrange(6):
      if list[i] in self.dic:
        self.dic[list[i]] += 1
      else:
        self.dic[list[i]] = 1

  def print_all(self):
    print "top = " + self.top + ", front = " + self.front + ", right = " + self.right + ", left = " + self.left + ", back = " + self.back + ", bottom = " + self.bottom

  def roll_N(self):
    temp = self.top
    self.top = self.front
    self.front = self.bottom
    self.bottom = self.back
    self.back = temp

  def roll_S(self):
    temp = self.top
    self.top = self.back
    self.back = self.bottom
    self.bottom = self.front
    self.front = temp

  def roll_W(self):
    temp = self.top
    self.top = self.right
    self.right = self.bottom
    self.bottom = self.left
    self.left = temp

  def roll_E(self):
    temp = self.top
    self.top = self.left
    self.left = self.bottom
    self.bottom = self.right
    self.right = temp

  def roll_C(self):
    temp = self.front
    self.front = self.right
    self.right = self.back
    self.back = self.left
    self.left = temp

  def random_roll(self):
    ram = random.randint(1, 4)
    if ram == 1:
      self.roll_E()
    elif ram == 2:
      self.roll_N()
    elif ram == 3:
      self.roll_S()
    else:
      self.roll_W()

  def getDifference(self, dice):
    same_list = []
    different_list = []
    if self.top == dice.top:
      same_list.append("top")
    else:
      different_list.append("top")
    if self.front == dice.front:
      same_list.append("front")
    else:
      different_list.append("front")
    if self.left == dice.left:
      same_list.append("left")
    else:
      different_list.append("left")
    if self.back == dice.back:
      same_list.append("back")
    else:
      different_list.append("back")
    if self.right == dice.right:
      same_list.append("right")
    else:
      different_list.append("right")
    if self.bottom == dice.bottom:
      same_list.append("bottom")
    else:
      different_list.append("bottom")

    result_list = [same_list, different_list]
    return result_list

  def getList(self):
    list = [self.top, self.front, self.right, self.left, self.back, self.bottom]
    return list

def print_dices():
  print "first dice: "
  first_dice.print_all()
  print "second dice: "
  second_dice.print_all()
  print first_dice.dic

line = "#######################################"


def judgeDices(first_dice, second_dice):
  flag = False
  num = 0
  debug = 0
  while num < 4:
    # debug += 1
    # if debug > 10:
    #   break
    # print line

    dic1_keys = first_dice.dic.keys()
    for i in xrange(len(dic1_keys)):
      if first_dice.dic[dic1_keys[i]] != second_dice.dic[dic1_keys[i]]:
        num = 4
        break

    for i in xrange(len(dic1_keys)):
      if first_dice.dic[dic1_keys[i]] == 6 or first_dice.dic[dic1_keys[i]] == 5:
        num = 4
        flag = True
        break

    # print_dices()

    diferece = first_dice.getDifference(second_dice)
    # print diferece

    same_num = len(diferece[0])
    if same_num == 6:
      break
    elif same_num == 5:
      num = 4
      break

    if "front" in diferece[0] or "back" in diferece[0]:
      first_dice.roll_W()
      num += 1
    elif "left" in diferece[0] or "right" in diferece[0]:
      first_dice.roll_S()
      num += 1
    elif "top" in diferece[0] or "bottom" in diferece[0]:
      first_dice.roll_C()
      num += 1
    else:
      first_dice.random_roll()

  if flag == True:
    return True
  elif num == 4:
    return False
  else:
    return True

n = int(raw_input())
first_dice = Dice(raw_input().split(" "))
result = True
for i in xrange(n - 1):
  second_dice = Dice(raw_input().split(" "))
  result = judgeDices(first_dice, second_dice)
  if result == False:
    break
if result == True:
  print "Yes"
else:
  print "No"