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: Runtime Error

Solution code:
class Dice():
	def __init__(self):
		self.number = [_ for _ in range(6)]
		self.work = [_ for _ in range(6)]
		self.order = "NNNNWNNNWNNNENNNENNNWNNN"
	def setNumber(self,n0,n1,n2,n3,n4,n5):
		self.number[0] = n0
		self.number[1] = n1
		self.number[2] = n2
		self.number[3] = n3
		self.number[4] = n4
		self.number[5] = n5

	def roll(self,loc):
		for _ in range(6):
			self.work[_] = self.number[_]
		if loc == "E":
			self.setNumber(self.work[3],self.work[1],self.work[0],self.work[5],self.work[4],self.work[2])
		elif loc == "N":
			self.setNumber(self.work[1],self.work[5],self.work[2],self.work[3],self.work[0],self.work[4])
		elif loc == "S":
			self.setNumber(self.work[4],self.work[0],self.work[2],self.work[3],self.work[5],self.work[1])
		elif loc == "W":
			self.setNumber(self.work[2],self.work[1],self.work[5],self.work[0],self.work[4],self.work[3])
	def get_top(self):
		return self.number[0]
	def get_right(self,n1,n2):
		if(n1 == self.number[0]):
			if(n2 == self.number[1]): return(self.number[2])
			elif(n2 == self.number[2]): return(self.number[4])
			elif(n2 == self.number[3]): return(self.number[1])
			elif(n2 == self.number[4]): return(self.number[3])
		elif(n1 == self.number[1]):
                        if(n2 == self.number[0]): return(self.number[3])
                        elif(n2 == self.number[2]): return(self.number[0])
                        elif(n2 == self.number[3]): return(self.number[5])
                        elif(n2 == self.number[5]): return(self.number[2])
		elif(n1 == self.number[2]):
                        if(n2 == self.number[0]): return(self.number[1])
                        elif(n2 == self.number[1]): return(self.number[5])
                        elif(n2 == self.number[4]): return(self.number[0])
                        elif(n2 == self.number[5]): return(self.number[4])
		elif(n1 == self.number[3]):
                        if(n2 == self.number[0]): return(self.number[4])
                        elif(n2 == self.number[1]): return(self.number[0])
                        elif(n2 == self.number[4]): return(self.number[5])
                        elif(n2 == self.number[5]): return(self.number[1])
		elif(n1 == self.number[4]):
                        if(n2 == self.number[0]): return(self.number[2])
                        elif(n2 == self.number[2]): return(self.number[5])
                        elif(n2 == self.number[3]): return(self.number[0])
                        elif(n2 == self.number[5]): return(self.number[3])
		elif(n1 == self.number[5]):
                        if(n2 == self.number[1]): return(self.number[3])
                        elif(n2 == self.number[2]): return(self.number[1])
                        elif(n2 == self.number[3]): return(self.number[4])
                        elif(n2 == self.number[4]): return(self.number[2])

	def equals(self,another):
		ret = False
		for i in range(len(self.order)):
			self.roll(self.order[i])
			flg = True
			for k in range(6):
				if self.number[k] != another.number[k]:
					flg = False
					break
			if flg == True:
				return True
		return ret

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

flag = True
for _ in range(n-1):
	for i in range(i+1,n):
	if(dice[_].equals(dice[_+1])):
		flag = False
		break

print("Yes" if flag else "No")

Submission status: Runtime Error

Solution code:
class Dice():
	def __init__(self):
		self.number = [_ for _ in range(6)]
		self.work = [_ for _ in range(6)]
		self.order = "NNNNWNNNWNNNENNNENNNWNNN"
	def setNumber(self,n0,n1,n2,n3,n4,n5):
		self.number[0] = n0
		self.number[1] = n1
		self.number[2] = n2
		self.number[3] = n3
		self.number[4] = n4
		self.number[5] = n5

	def roll(self,loc):
		for _ in range(6):
			self.work[_] = self.number[_]
		if loc == "E":
			self.setNumber(self.work[3],self.work[1],self.work[0],self.work[5],self.work[4],self.work[2])
		elif loc == "N":
			self.setNumber(self.work[1],self.work[5],self.work[2],self.work[3],self.work[0],self.work[4])
		elif loc == "S":
			self.setNumber(self.work[4],self.work[0],self.work[2],self.work[3],self.work[5],self.work[1])
		elif loc == "W":
			self.setNumber(self.work[2],self.work[1],self.work[5],self.work[0],self.work[4],self.work[3])
	def get_top(self):
		return self.number[0]
	def get_right(self,n1,n2):
		if(n1 == self.number[0]):
			if(n2 == self.number[1]): return(self.number[2])
			elif(n2 == self.number[2]): return(self.number[4])
			elif(n2 == self.number[3]): return(self.number[1])
			elif(n2 == self.number[4]): return(self.number[3])
		elif(n1 == self.number[1]):
                        if(n2 == self.number[0]): return(self.number[3])
                        elif(n2 == self.number[2]): return(self.number[0])
                        elif(n2 == self.number[3]): return(self.number[5])
                        elif(n2 == self.number[5]): return(self.number[2])
		elif(n1 == self.number[2]):
                        if(n2 == self.number[0]): return(self.number[1])
                        elif(n2 == self.number[1]): return(self.number[5])
                        elif(n2 == self.number[4]): return(self.number[0])
                        elif(n2 == self.number[5]): return(self.number[4])
		elif(n1 == self.number[3]):
                        if(n2 == self.number[0]): return(self.number[4])
                        elif(n2 == self.number[1]): return(self.number[0])
                        elif(n2 == self.number[4]): return(self.number[5])
                        elif(n2 == self.number[5]): return(self.number[1])
		elif(n1 == self.number[4]):
                        if(n2 == self.number[0]): return(self.number[2])
                        elif(n2 == self.number[2]): return(self.number[5])
                        elif(n2 == self.number[3]): return(self.number[0])
                        elif(n2 == self.number[5]): return(self.number[3])
		elif(n1 == self.number[5]):
                        if(n2 == self.number[1]): return(self.number[3])
                        elif(n2 == self.number[2]): return(self.number[1])
                        elif(n2 == self.number[3]): return(self.number[4])
                        elif(n2 == self.number[4]): return(self.number[2])

	def equals(self,another):
		ret = False
		for i in range(len(self.order)):
			self.roll(self.order[i])
			flg = True
			for k in range(6):
				if self.number[k] != another.number[k]:
					flg = False
					break
			if flg == True:
				return True
		return ret

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

flag = True
for _ in range(n-1):
	for i in range(i+1,n):
    	if(dice[_].equals(dice[i])):
	    	flag = False
	    	break

print("Yes" if flag else "No")

Submission status: Runtime Error

Solution code:
class Dice():
	def __init__(self):
		self.number = [_ for _ in range(6)]
		self.work = [_ for _ in range(6)]
		self.order = "NNNNWNNNWNNNENNNENNNWNNN"
	def setNumber(self,n0,n1,n2,n3,n4,n5):
		self.number[0] = n0
		self.number[1] = n1
		self.number[2] = n2
		self.number[3] = n3
		self.number[4] = n4
		self.number[5] = n5

	def roll(self,loc):
		for _ in range(6):
			self.work[_] = self.number[_]
		if loc == "E":
			self.setNumber(self.work[3],self.work[1],self.work[0],self.work[5],self.work[4],self.work[2])
		elif loc == "N":
			self.setNumber(self.work[1],self.work[5],self.work[2],self.work[3],self.work[0],self.work[4])
		elif loc == "S":
			self.setNumber(self.work[4],self.work[0],self.work[2],self.work[3],self.work[5],self.work[1])
		elif loc == "W":
			self.setNumber(self.work[2],self.work[1],self.work[5],self.work[0],self.work[4],self.work[3])
	def get_top(self):
		return self.number[0]
	def get_right(self,n1,n2):
		if(n1 == self.number[0]):
			if(n2 == self.number[1]): return(self.number[2])
			elif(n2 == self.number[2]): return(self.number[4])
			elif(n2 == self.number[3]): return(self.number[1])
			elif(n2 == self.number[4]): return(self.number[3])
		elif(n1 == self.number[1]):
                        if(n2 == self.number[0]): return(self.number[3])
                        elif(n2 == self.number[2]): return(self.number[0])
                        elif(n2 == self.number[3]): return(self.number[5])
                        elif(n2 == self.number[5]): return(self.number[2])
		elif(n1 == self.number[2]):
                        if(n2 == self.number[0]): return(self.number[1])
                        elif(n2 == self.number[1]): return(self.number[5])
                        elif(n2 == self.number[4]): return(self.number[0])
                        elif(n2 == self.number[5]): return(self.number[4])
		elif(n1 == self.number[3]):
                        if(n2 == self.number[0]): return(self.number[4])
                        elif(n2 == self.number[1]): return(self.number[0])
                        elif(n2 == self.number[4]): return(self.number[5])
                        elif(n2 == self.number[5]): return(self.number[1])
		elif(n1 == self.number[4]):
                        if(n2 == self.number[0]): return(self.number[2])
                        elif(n2 == self.number[2]): return(self.number[5])
                        elif(n2 == self.number[3]): return(self.number[0])
                        elif(n2 == self.number[5]): return(self.number[3])
		elif(n1 == self.number[5]):
                        if(n2 == self.number[1]): return(self.number[3])
                        elif(n2 == self.number[2]): return(self.number[1])
                        elif(n2 == self.number[3]): return(self.number[4])
                        elif(n2 == self.number[4]): return(self.number[2])

	def equals(self,another):
		ret = False
		for i in range(len(self.order)):
			self.roll(self.order[i])
			flg = True
			for k in range(6):
				if self.number[k] != another.number[k]:
					flg = False
					break
			if flg == True:
				return True
		return ret

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

flag = True
for _ in range(n-1):
	for i in range(i+1,n):
		if(dice[_].equals(dice[i])):
			flag = False
			break

print("Yes" if flag else "No")

Submission status: Runtime Error

Solution code:
mask = [[i for i in range(6)], (1, 5, 2, 3, 0, 4), (2, 1, 5, 0, 4,3),(3, 1, 0, 5, 4, 2), (4, 0, 2, 3, 5, 1)]
mask += [[mask[1][i] for i in mask[1]]]

def set_top(dice, top):
    return [dice[i] for i in mask[top]]

def twist(dice):
    return [dice[i] for i in (0, 3, 1, 4, 2, 5)]

def equal(dice1, dice2):
    if sorted(dice1) != sorted(dice2):
        return False
    
    for i in range(6):
        if i:tmp_dice = set_top(dice2, i)
        for j in range(4):
            if j:tmp_dice = twist(tmp_dice)
            if dice1 == tmp_dice:
                return True
    return False

def diff_check_all(dices, n):
    for i in range(n -1):
        for j in range(i + 1, n):
            if equal(dices[i], dices[j]):
                return False
    return True
            

n = int(input())
dices = [input().split() for _ in range(n)]

print('Yes' if diff_check_all(dices, n) else 'No')

Submission status: Runtime Error

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 == other.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: Runtime Error

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)

n = int(input())
dice_list = [input().split() for i in range(n)]

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: Runtime Error

Solution code:
import itertools


def roll(dice, commands):
    for command in commands:
        if command == 'N':
            dice[0], dice[1], dice[5], dice[4] = dice[1], dice[5], dice[4], dice[0]
        elif command == 'W':
            dice[0], dice[3], dice[5], dice[2] = dice[2], dice[0], dice[3], dice[5]

A = list(map(int, input().split()))
B = list(map(int, input().split()))
for i in range(4):
    for j in range(4):
        for commands in itertools.permutations('N' * i + 'W' * j):
            a = A[::]
            roll(a, commands)
            if B == a:
                print('Yes')
                exit()
print('No')

Submission status: Runtime Error

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())
dices = []
for i in xrange(n):
  dices.append(Dice(raw_input().split(" ")))
result = False
for i in xrange(n - 1):
  for j in xrange(i + 1, n):
    first_dice = dices[i]
    second_dice = dices[j]
    result = judgeDices(first_dice, second_dice)
    # print result
    if result:
      break
  if result:
    break

if result:
  print "No"
else:
  print "Yes"

Submission status: Runtime Error

Solution code:
#-*- coding:utf-8 -*-
import sys
n = input()
rolls =[]
for x in xrange(n):
    rolls.append(raw_input().split())
#??????????????¨??????????????????????????????
#?????´????????????????????¨??????????????£???????????§??????
for l1 in xrange(n):
    for l2 in xrange(n):
        #??????????????????????????????
        #?????????????????????????????´????????????????????????????????????????????£????????????????????????
        if l1==l2:
            break
        rolls_copy = rolls
        testpare = (rolls_copy[l1][0],rolls_copy[l1][5])
        testparerev = (rolls_copy[l1][5],rolls_copy[l1][0])
        rolls2pare = [(rolls_copy[l2][0],rolls_copy[l2][5]),(rolls_copy[l2][2],rolls_copy[l2][3]),(rolls_copy[l2][1],rolls_copy[l2][4])]
        #??????????????¢????????¢??§?????´??????????????????????????????????¢????
        #??¨??¨????????¢?????£????????????????????´???????????¢???3????????¨??????????¢????????????????????????????
        if testpare in rolls2pare:
            pareps = rolls2pare.index(testpare)
            revflag = False
        elif testparerev in rolls2pare:
            pareps = rolls2pare.index(testparerev)
            revflag = True
        else:
            break
        #?¬???????????????¢??\????????¨????????????????????£??????????¢????
        #??????????????????????????????
        li1 = [rolls_copy[l1][1],rolls_copy[l1][2],rolls_copy[l1][4],rolls_copy[l1][3]]
        # print pareps
        if pareps==0:
            if revflag:
                tmp = rolls_copy[l2][2]
                rolls_copy[l2][2] = rolls_copy[l2][3]
                rolls_copy[l2][3] = tmp
            li2 = [rolls_copy[l2][1],rolls_copy[l2][2],rolls_copy[l2][4],rolls_copy[l2][3]]
        elif pareps==1:
            if revflag:
                tmp = rolls_copy[l2][1]
                rolls_copy[l2][1] = rolls_copy[l2][4]
                rolls_copy[l2][4] = tmp
            li2 = [rolls_copy[l2][0],rolls_copy[l2][1],rolls_copy[l2][5],rolls_copy[l2][4]]
        elif pareps==2:
            if revflag:
                tmp = rolls_copy[l2][0]
                rolls_copy[l2][0] = rolls_copy[l2][5]
                rolls_copy[l2][5] = tmp
            li2 = [rolls_copy[l2][0],rolls_copy[l2][3],rolls_copy[l2][5],rolls_copy[l2][2]]
        else:
            break
        #?????????????????´?¢????
        # print li1
        # print li2
        i=0
        j=li2.index(li1[0])
        matchflag = True#else??\??£???????????´?????????
        for x in xrange(4):
            # print "%s : %s"%(li1[i],li2[j])
            if li1[i]==li2[j]:
                j+=1
                i+=1
            else:
                matchflag =False
                break
            if i>3:
                i=0
            if j>3:
                j=0
        if matchflag:
            print "No"
            sys.exit(0)
print "Yes"

Submission status: Runtime Error

Solution code:
def cache_dice(d):
    return dlist.append((d, {v: k for k, v in enumerate(d)}))


n, d1 = int(input()), tuple(map(int, input().split()))
dlist = []

cache_dice(d1)

dms = ((1, 2, 4, 3), (0, 3, 5, 2), (0, 1, 5, 4), (0, 4, 5, 1), (0, 2, 5, 3), (1, 3, 4, 2))

for _ in range(n - 1):
    d2 = tuple(map(int, input().split()))
    for (dl, dd) in dlist:
        if d2[0] not in dd:
            cache_dice(d2)
            continue
        d0 = dd[d2[0]]
        dm = dms[d0]
        if dd[d2[1]] not in dm:
            cache_dice(d2)
            continue
        dmi = dm.index(dd[d2[1]])
        if d2[2] == d1[dm[(dmi + 1) % 4]] \
                and d2[3] == d1[dm[(dmi + 3) % 4]] \
                and d2[4] == d1[dm[(dmi + 2) % 4]] \
                and d2[5] == d1[5 - d0]:
            print('No')
            exit(0)
    cache_dice(d2)
print('Yes')

Submission status: Runtime Error

Solution code:
import math
a,b,C = map(float,input().split())
C_rad=math.pi*C/180
print("{0:.8f}".format(math.sin(C_rad)*a*b/2))
print("{0:.8f}".format(a+b+math.sqrt(a**2+b**2-2*a*b*math.cos(C_rad))))
print("{0:.8f}".format(b*math.sin(C_rad)))

Submission status: Runtime Error

Solution code:
# coding: utf-8
# ?????????????????¨????????????
class Dice(object):
	def __init__(self, L=[1, 2, 3, 4, 5, 6]):
		# ????????¶???
		self.dice = (L[1], L[4]), (L[2], L[3]), (L[0], L[5]) # x, y, z
		self.ax = [[0, False], [1, False], [2, False]]
		self.axmap = [0, 1, 2]
		self.mm = {"N": (0, 2), "S": (2, 0), "E": (1, 2), "W": (2, 1), "R": (0, 1), "L": (1, 0)}

	def rotate(self, dir):
		def rot(k, r):
			t = self.axmap[r]
			self.axmap[k], self.axmap[r] = t, self.axmap[k]
			self.ax[t][1] = not self.ax[t][1]

		rot(*self.mm[dir])
	
	def reverse(self, ax):
		self.ax[ax][1] = not self.ax[ax][1]
		rev = [(1, 2), (2, 0), (0, 1)][ax]
		self.axmap[rev[1]], self.axmap[rev[0]] = self.axmap[rev[0]], self.axmap[rev[1]]

	def front(self): return self.value(0, True)
	def rear(self): return self.value(0, False)
	def right(self): return self.value(1, True)
	def left(self): return self.value(1, False)
	def top(self): return self.value(2, True)
	def bottom(self): return self.value(2, False)
	def value(self, ax, d):
		a = self.ax[self.axmap[ax]]
		return self.dice[a[0]][a[1] if d else not a[1]]

	def __eq__(self, dice):
		#???????????????????????????????¢??????????
		# z???????????§????????????????????´??????????????????????????°?????????????????§NG
		# ????????\?????????z????????????????????¢??§?????´????????????????????§????????¢??????????????´??????????????°NG
		# z???????????´?????????
		idx = -1
		for i, ax in enumerate(self.dice):
			if dice.top() in ax and dice.bottom() in ax:
				idx = i
				# i = 0 = x => 0, 2 ?????????
				# i = 1 = y => 1, 2 ?????????
				# i = 2 = z => ????????????????????±?????????
				if i != 2:
					self.reverse((i+1)%2)
				break

		if idx==-1:
			return False
		
		# z(2)?????????????¢????
		if self.top()!=dice.top():
			self.reverse(2)

		# x, y???????¢????
		for _ in range(4):
			r = 0
			for x in range(2):
				for b in (True, False):
					if self.value(x, b)!=dice.value(x, b):
						break
					else:
						r += 1

				if r<2:
					break

			if r==4:
				return True
			else:
				self.rotate("R")

		return False

if __name__=="__main__":
	n = input()
	dices = [Dice(raw_input().split())]
	for _ in range(1, n):
		dice = Dice(raw_input().split())
		for d in dices:
			if dice==d:
				print("No")
				exit(0)
		dices.append(dice)
	print("Yes")

Submission status: Runtime Error

Solution code:
# coding: utf-8
# ?????????????????¨????????????
class Dice(object):
	def __init__(self, L=[1, 2, 3, 4, 5, 6]):
		# ????????¶???
		self.dice = (L[1], L[4]), (L[2], L[3]), (L[0], L[5]) # x, y, z
		self.ax = [[0, False], [1, False], [2, False]]
		self.axmap = [0, 1, 2]
		self.mm = {"N": (0, 2), "S": (2, 0), "E": (1, 2), "W": (2, 1), "R": (0, 1), "L": (1, 0)}

	def rotate(self, dir):
		def rot(k, r):
			t = self.axmap[r]
			self.axmap[k], self.axmap[r] = t, self.axmap[k]
			self.ax[t][1] = not self.ax[t][1]

		rot(*self.mm[dir])
	
	def reverse(self, ax):
		self.ax[ax][1] = not self.ax[ax][1]
		rev = [(1, 2), (2, 0), (0, 1)][ax]
		self.axmap[rev[1]], self.axmap[rev[0]] = self.axmap[rev[0]], self.axmap[rev[1]]

	def front(self): return self.value(0, True)
	def rear(self): return self.value(0, False)
	def right(self): return self.value(1, True)
	def left(self): return self.value(1, False)
	def top(self): return self.value(2, True)
	def bottom(self): return self.value(2, False)
	def value(self, ax, d):
		a = self.ax[self.axmap[ax]]
		return self.dice[a[0]][a[1] if d else not a[1]]

	def __eq__(self, dice):
		#???????????????????????????????¢??????????
		# z???????????§????????????????????´??????????????????????????°?????????????????§NG
		# ????????\?????????z????????????????????¢??§?????´????????????????????§????????¢??????????????´??????????????°NG
		# z???????????´?????????
		idx = -1
		for i, ax in enumerate(self.dice):
			if dice.top() in ax and dice.bottom() in ax:
				idx = i
				# i = 0 = x => 0, 2 ?????????
				# i = 1 = y => 1, 2 ?????????
				# i = 2 = z => ????????????????????±?????????
				if i != 2:
					self.reverse((i+1)%2)
				break

		if idx==-1:
			return False
		
		# z(2)?????????????¢????
		if self.top()!=dice.top():
			self.reverse(2)

		# x, y???????¢????
		for _ in range(4):
			r = 0
			for x in range(2):
				for b in (True, False):
					if self.value(x, b)!=dice.value(x, b):
						break
					else:
						r += 1

				if r<2:
					break

			if r==4:
				return True
			else:
				self.rotate("R")

		return False

if __name__=="__main__":
	n = input()
	dices = [Dice(input().split())]
	for _ in range(1, n):
		dice = Dice(input().split())
		for d in dices:
			if dice==d:
				print("No")
				exit(0)
		dices.append(dice)
	print("Yes")