python code_festival_2018_final_d

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python code_festival_2018_final_d相关的知识,希望对你有一定的参考价值。

# immigrated
import sys
from string import ascii_letters

ascii_orders = sorted(ord(c) for c in ascii_letters)

n = int(input())
v1 = []
v2 = []
cnt = [[[0] * 128 for _ in range(128)] for _ in range(128)]
# cnt[i][j][k] = 文字ijkを部分列に含む文字列の個数
st1 = [0] * 128
st2 = [[0] * 128 for _ in range(128)]
for i, s in enumerate(sys.stdin.readlines()):
    l = len(s)
    v1.clear()
    v2.clear()
    for j, c in enumerate(s):
        v = ord(c)
        for u in v1:
            if st2[u][v] == 0:
                st2[u][v] = j + 1
                v2.append((u, v))
        if st1[v] == 0:
            v1.append(v)
        st1[v] = j + 1
    for u, v in v2:
        for b in v1:
            if st2[u][v] < st1[b]:
                cnt[u][v][b] += 1
        st2[u][v] = 0
    for b in v1:
        st1[b] = 0
    print(i, s, v1, v2)
print(st1)
# print('\n'.join(str([st2[i][j] for j in ascii_orders]) for i in ascii_orders))
print('\n'.join(str([cnt[i][j] for j in ascii_orders]) for i in ascii_orders))
m = 0
ret = [0] * 3
for i in ascii_orders:
    for j in ascii_orders:
        for k in ascii_orders:
            if cnt[i][j][k] > m:
                ret[0] = i
                ret[1] = j
                ret[2] = k
                m = cnt[i][j][k]

print(''.join(chr(i) for i in ret))

以上是关于python code_festival_2018_final_d的主要内容,如果未能解决你的问题,请参考以下文章

python 2018.7.27 属性

2018-07-05-Python全栈开发day25-python中的继承

码农要求_python豆瓣_2018校招

python nav_2018

2018/11/16(python(迭代器与生成器))

Neil_Python_2018/9/14