結果

問題 No.2715 Unique Chimatagram
ユーザー titiatitia
提出日時 2024-04-05 22:20:21
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 565 ms / 2,000 ms
コード長 876 bytes
コンパイル時間 523 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 77,664 KB
最終ジャッジ日時 2024-04-05 22:20:27
合計ジャッジ時間 5,694 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
55,604 KB
testcase_01 AC 41 ms
55,604 KB
testcase_02 AC 42 ms
55,604 KB
testcase_03 AC 43 ms
55,604 KB
testcase_04 AC 42 ms
55,600 KB
testcase_05 AC 42 ms
55,604 KB
testcase_06 AC 41 ms
55,604 KB
testcase_07 AC 40 ms
55,604 KB
testcase_08 AC 71 ms
72,820 KB
testcase_09 AC 95 ms
77,040 KB
testcase_10 AC 74 ms
73,708 KB
testcase_11 AC 70 ms
72,812 KB
testcase_12 AC 68 ms
72,812 KB
testcase_13 AC 69 ms
72,812 KB
testcase_14 AC 70 ms
72,820 KB
testcase_15 AC 70 ms
72,812 KB
testcase_16 AC 71 ms
72,824 KB
testcase_17 AC 70 ms
72,812 KB
testcase_18 AC 72 ms
73,068 KB
testcase_19 AC 85 ms
77,664 KB
testcase_20 AC 73 ms
72,940 KB
testcase_21 AC 74 ms
73,056 KB
testcase_22 AC 81 ms
73,184 KB
testcase_23 AC 73 ms
72,940 KB
testcase_24 AC 74 ms
73,568 KB
testcase_25 AC 71 ms
72,800 KB
testcase_26 AC 73 ms
73,068 KB
testcase_27 AC 73 ms
73,056 KB
testcase_28 AC 123 ms
77,168 KB
testcase_29 AC 108 ms
77,308 KB
testcase_30 AC 108 ms
77,160 KB
testcase_31 AC 120 ms
77,424 KB
testcase_32 AC 209 ms
77,432 KB
testcase_33 AC 40 ms
55,604 KB
testcase_34 AC 42 ms
55,604 KB
testcase_35 AC 42 ms
55,604 KB
testcase_36 AC 42 ms
55,604 KB
testcase_37 AC 41 ms
55,604 KB
testcase_38 AC 54 ms
64,304 KB
testcase_39 AC 565 ms
77,052 KB
testcase_40 AC 125 ms
77,032 KB
testcase_41 AC 61 ms
68,264 KB
testcase_42 AC 60 ms
70,316 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

from collections import Counter

n=int(input())
S=[sorted(input().strip()) for i in range(n)]
CS=[]
for i in range(n):
    CS.append(Counter(S[i]))

for i in range(n):
    if i+1<n and S[i]==S[i+1]:
        continue
    if i-1>=0 and S[i]==S[i-1]:
        continue

    for x in "abcdefghijklmnopqrstuvwxyz":
        T=S[i]+[x]
        C=Counter(T)
        flag=1

        for j in range(n):
            if i==j:
                continue

            count=0
            fflag=1

            for y in C:
                if C[y]<CS[j][y]:
                    fflag=0
                    break
                else:
                    count+=C[y]-CS[j][y]

            if fflag==1 and count==1:
                flag=0
                break

        if flag==1:
            print("".join(T))
            exit()
        
        
print(-1)
0