結果

問題 No.2715 Unique Chimatagram
ユーザー ThetaTheta
提出日時 2024-04-10 15:08:00
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,056 bytes
コンパイル時間 491 ms
コンパイル使用メモリ 82,136 KB
実行使用メモリ 79,772 KB
最終ジャッジ日時 2024-04-10 15:08:22
合計ジャッジ時間 7,763 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 60 ms
64,128 KB
testcase_01 AC 59 ms
63,872 KB
testcase_02 AC 60 ms
63,872 KB
testcase_03 WA -
testcase_04 AC 65 ms
63,872 KB
testcase_05 AC 59 ms
64,128 KB
testcase_06 AC 64 ms
64,128 KB
testcase_07 AC 59 ms
63,872 KB
testcase_08 AC 120 ms
78,324 KB
testcase_09 WA -
testcase_10 AC 129 ms
78,924 KB
testcase_11 AC 134 ms
79,168 KB
testcase_12 AC 127 ms
78,592 KB
testcase_13 AC 133 ms
78,692 KB
testcase_14 AC 125 ms
78,564 KB
testcase_15 AC 128 ms
78,832 KB
testcase_16 AC 126 ms
78,572 KB
testcase_17 AC 128 ms
79,064 KB
testcase_18 AC 130 ms
79,772 KB
testcase_19 AC 130 ms
79,184 KB
testcase_20 AC 132 ms
78,720 KB
testcase_21 AC 137 ms
78,956 KB
testcase_22 AC 137 ms
79,168 KB
testcase_23 AC 132 ms
79,232 KB
testcase_24 AC 130 ms
79,232 KB
testcase_25 AC 129 ms
78,848 KB
testcase_26 AC 130 ms
78,976 KB
testcase_27 AC 130 ms
79,104 KB
testcase_28 AC 125 ms
78,464 KB
testcase_29 AC 122 ms
78,720 KB
testcase_30 AC 131 ms
78,264 KB
testcase_31 AC 139 ms
78,220 KB
testcase_32 AC 125 ms
78,276 KB
testcase_33 AC 59 ms
63,744 KB
testcase_34 AC 58 ms
64,000 KB
testcase_35 AC 59 ms
64,000 KB
testcase_36 AC 59 ms
63,744 KB
testcase_37 AC 59 ms
64,256 KB
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 AC 110 ms
78,016 KB
testcase_42 AC 97 ms
77,696 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import Counter
from string import ascii_lowercase


def main():
    N = int(input())
    S = [input() for _ in range(N)]
    S_ctrs = list(map(Counter, S))

    S_sorted = list(map(lambda elm: "".join(sorted(elm)), S))
    S_cand = set()
    S_sorted_ctr = Counter(S_sorted)
    for sort_elm, elm in zip(S_sorted, S):
        if S_sorted_ctr[sort_elm] == 1:
            S_cand.add(elm)

    if not S_cand:
        print(-1)
        return

    for elm in S_cand:
        for add_letter in ascii_lowercase:
            tmp_ctr = Counter(elm)
            tmp_ctr[add_letter] += 1
            for other_elm, other_ctr in zip(S, S_ctrs):
                if other_elm == elm:
                    continue
                tmp_ctr.subtract(other_ctr)
                tmp_ctr_ctr = Counter(tmp_ctr.values())
                if set(tmp_ctr_ctr).issubset({0, 1}) and tmp_ctr_ctr[1] == 1:
                    break
            else:
                print(elm + add_letter)
                return
    print(-1)


if __name__ == "__main__":
    main()
0