結果

問題 No.2715 Unique Chimatagram
ユーザー kk0414kk0414
提出日時 2024-04-10 23:21:47
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 814 ms / 2,000 ms
コード長 876 bytes
コンパイル時間 300 ms
コンパイル使用メモリ 82,624 KB
実行使用メモリ 77,312 KB
最終ジャッジ日時 2024-04-10 23:21:53
合計ジャッジ時間 5,691 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 31 ms
53,288 KB
testcase_01 AC 33 ms
53,384 KB
testcase_02 AC 33 ms
53,764 KB
testcase_03 AC 33 ms
52,588 KB
testcase_04 AC 36 ms
53,276 KB
testcase_05 AC 36 ms
52,652 KB
testcase_06 AC 38 ms
52,680 KB
testcase_07 AC 37 ms
53,064 KB
testcase_08 AC 59 ms
68,088 KB
testcase_09 AC 58 ms
70,772 KB
testcase_10 AC 57 ms
68,812 KB
testcase_11 AC 59 ms
68,720 KB
testcase_12 AC 58 ms
68,180 KB
testcase_13 AC 59 ms
68,968 KB
testcase_14 AC 71 ms
75,004 KB
testcase_15 AC 69 ms
73,824 KB
testcase_16 AC 54 ms
68,176 KB
testcase_17 AC 56 ms
67,636 KB
testcase_18 AC 54 ms
70,004 KB
testcase_19 AC 54 ms
69,624 KB
testcase_20 AC 55 ms
71,216 KB
testcase_21 AC 59 ms
69,376 KB
testcase_22 AC 59 ms
70,132 KB
testcase_23 AC 59 ms
69,660 KB
testcase_24 AC 61 ms
70,736 KB
testcase_25 AC 52 ms
70,500 KB
testcase_26 AC 53 ms
69,772 KB
testcase_27 AC 53 ms
71,208 KB
testcase_28 AC 111 ms
76,980 KB
testcase_29 AC 78 ms
76,720 KB
testcase_30 AC 91 ms
77,140 KB
testcase_31 AC 70 ms
73,888 KB
testcase_32 AC 150 ms
76,840 KB
testcase_33 AC 33 ms
52,676 KB
testcase_34 AC 33 ms
52,748 KB
testcase_35 AC 32 ms
53,248 KB
testcase_36 AC 32 ms
52,256 KB
testcase_37 AC 33 ms
53,260 KB
testcase_38 AC 43 ms
62,524 KB
testcase_39 AC 220 ms
76,932 KB
testcase_40 AC 85 ms
77,312 KB
testcase_41 AC 814 ms
77,200 KB
testcase_42 AC 237 ms
76,684 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
L = [[0]*26 for _ in range(N)]
cand = []
for i in range(N):
    s = input()
    cand.append(s)
    for si in s:
        j = ord(si)-ord("a")
        L[i][j] += 1

for i in range(N):
    OK = [False] * N
    OK[i] = True
    skips = set()
    for j in range(N):
        if i==j:continue
        flag = False
        NG = []
        for k in range(26):
            if L[j][k] == L[i][k]:
                continue
            flag = True
            if L[j][k] - L[i][k] == 1:
                NG.append(k)
        OK[j] = flag
        if len(NG)==1:
            skips.add(NG[0])
    if all(OK) and len(skips) < 26 : break

if not all(OK):
    print("-1")
else:
    if len(skips)==26:
        print("-1")
    else:
        for x in range(26):
            if not x in skips:
                break
        ans = cand[i] + chr(x+ord("a"))
        print(ans)
        
0