結果

問題 No.2715 Unique Chimatagram
ユーザー 👑 tipstar0125tipstar0125
提出日時 2024-04-05 22:16:55
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 429 ms / 2,000 ms
コード長 1,005 bytes
コンパイル時間 509 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 76,688 KB
最終ジャッジ日時 2024-04-05 22:17:00
合計ジャッジ時間 5,645 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
53,460 KB
testcase_01 AC 35 ms
53,460 KB
testcase_02 AC 37 ms
53,460 KB
testcase_03 AC 37 ms
53,460 KB
testcase_04 AC 37 ms
53,460 KB
testcase_05 AC 37 ms
53,460 KB
testcase_06 AC 37 ms
53,460 KB
testcase_07 AC 37 ms
53,460 KB
testcase_08 AC 63 ms
68,568 KB
testcase_09 AC 66 ms
70,640 KB
testcase_10 AC 65 ms
70,652 KB
testcase_11 AC 64 ms
70,644 KB
testcase_12 AC 64 ms
70,644 KB
testcase_13 AC 63 ms
70,644 KB
testcase_14 AC 75 ms
73,376 KB
testcase_15 AC 81 ms
76,068 KB
testcase_16 AC 62 ms
68,568 KB
testcase_17 AC 62 ms
70,644 KB
testcase_18 AC 64 ms
70,644 KB
testcase_19 AC 75 ms
70,644 KB
testcase_20 AC 64 ms
70,652 KB
testcase_21 AC 66 ms
70,652 KB
testcase_22 AC 65 ms
70,652 KB
testcase_23 AC 64 ms
70,652 KB
testcase_24 AC 63 ms
70,644 KB
testcase_25 AC 65 ms
70,652 KB
testcase_26 AC 64 ms
70,644 KB
testcase_27 AC 63 ms
70,652 KB
testcase_28 AC 94 ms
76,292 KB
testcase_29 AC 81 ms
75,916 KB
testcase_30 AC 88 ms
76,296 KB
testcase_31 AC 69 ms
72,728 KB
testcase_32 AC 130 ms
76,292 KB
testcase_33 AC 36 ms
53,460 KB
testcase_34 AC 36 ms
53,460 KB
testcase_35 AC 37 ms
53,460 KB
testcase_36 AC 37 ms
53,460 KB
testcase_37 AC 37 ms
53,460 KB
testcase_38 AC 52 ms
63,936 KB
testcase_39 AC 268 ms
76,680 KB
testcase_40 AC 92 ms
75,924 KB
testcase_41 AC 429 ms
76,688 KB
testcase_42 AC 82 ms
76,556 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N=int(input())
S=[list(input()) for _ in range(N)]

for i in range(N):
    cnt1=[0 for _ in range(26)]
    for c in S[i]:
        cnt1[ord(c)-ord("a")]+=1
    sum1=sum(cnt1)
    ok=[True for _ in range(26)]

    for j in range(N):
        if i==j:continue
        cnt2=[0 for _ in range(26)]
        for c in S[j]:cnt2[ord(c)-ord("a")]+=1
        sum2=sum(cnt2)

        diff_cnt=0
        for k in range(26):
            diff_cnt+=abs(cnt1[k]-cnt2[k])
        
        if diff_cnt==0:
            for k in range(26):ok[k]=False
            break
        if diff_cnt==2 and sum1==sum2:
            b1=0
            b2=0
            for k in range(26):
                if cnt1[k]<cnt2[k]:b1+=1
                if cnt1[k]>cnt2[k]:b2+=1
            if b1==1 and b2==1:
                for k in range(26):
                    if cnt1[k]<cnt2[k]:ok[k]=False
    
    for n,b in enumerate(ok):
        if b:
            print("".join(S[i])+chr(n+ord("a")))
            exit(0)


print(-1)




        

        
0