#coding=utf-8
lookup = [
    [2, 5, 3, 4],
    [4, 3, 5, 2],
    [0, 4, 1, 5],
    [5, 1, 4, 0],
    [2, 0, 3, 1],
    [1, 3, 0, 2]
]
def check_seq(a, b):
    biaobing = a[0]
    a_index = 0
    b_index = 0
    for i, item in enumerate(b):
        if item == biaobing:
            b_index = i
    for _ in range(4):
        if a[a_index] != b[b_index]:
            return False
        a_index += 1
        a_index %= 4
        b_index += 1
        b_index %= 4
    return True
def take_seq(a, index):
    return [a[i] for i in index]
def whether_same(a, b):
    a_seq = take_seq(a, lookup[0])
    b_index = 0
    for i, item in enumerate(b):
        if item == a[0]:
            b_index = i
    b_seq = take_seq(b, lookup[b_index])
    return check_seq(a_seq, b_seq)
def solution(shaizi):
    visited = [False for _ in range(len(shaizi))]
    classes = []
    for i in range(len(shaizi)):
        num_same = 1
        if visited[i]:
            continue
        else:
            visited[i] = True
        for j in range(len(shaizi)):
            if not visited[j] and whether_same(shaizi[i], shaizi[j]):
                num_same += 1
                visited[j] = True
        classes.append(num_same)
    classes = sorted(classes, reverse=True)
    print(len(classes))
    for item in classes:
        print('{} '.format(item), end='')
import sys
if __name__ == "__main__":
    # 读取第一行的n
    n = int(sys.stdin.readline().strip())
    shaizi = []
    for i in range(n):
        # 读取每一行
        line = sys.stdin.readline().strip()
        # 把每一行的数字分隔后转化成int列表
        values = list(map(int, line.split()))
        shaizi.append(values)
    solution(shaizi)   想了半天,终于想明白判断两个骰子是否相等怎么写。。 
   一开始还以为分组得用并查集,没想到暴力循环就过了 
   写的很着急 大家就不要吐槽代码写的啰嗦了 就写了10分钟 
                              
                    
                    
                
            
                        
                        
                        
                        
                        
            
            
                    
                    
                            
全部评论
(1) 回帖