結果

問題 No.2715 Unique Chimatagram
ユーザー 👑 tipstar0125tipstar0125
提出日時 2024-04-05 22:06:48
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 986 bytes
コンパイル時間 143 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 76,556 KB
最終ジャッジ日時 2024-04-05 22:06:53
合計ジャッジ時間 4,975 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
53,460 KB
testcase_01 AC 38 ms
53,460 KB
testcase_02 AC 37 ms
53,460 KB
testcase_03 AC 36 ms
53,460 KB
testcase_04 AC 37 ms
53,460 KB
testcase_05 AC 37 ms
53,460 KB
testcase_06 AC 36 ms
53,460 KB
testcase_07 AC 36 ms
53,460 KB
testcase_08 AC 65 ms
68,568 KB
testcase_09 AC 72 ms
70,640 KB
testcase_10 AC 65 ms
70,652 KB
testcase_11 AC 65 ms
70,644 KB
testcase_12 AC 66 ms
70,644 KB
testcase_13 AC 64 ms
70,644 KB
testcase_14 AC 75 ms
73,372 KB
testcase_15 AC 75 ms
73,892 KB
testcase_16 AC 64 ms
68,568 KB
testcase_17 AC 64 ms
70,644 KB
testcase_18 AC 65 ms
70,644 KB
testcase_19 AC 65 ms
70,644 KB
testcase_20 AC 65 ms
70,652 KB
testcase_21 AC 68 ms
70,652 KB
testcase_22 AC 66 ms
70,652 KB
testcase_23 AC 69 ms
70,652 KB
testcase_24 AC 69 ms
70,644 KB
testcase_25 AC 65 ms
70,652 KB
testcase_26 AC 64 ms
70,644 KB
testcase_27 AC 65 ms
70,652 KB
testcase_28 AC 93 ms
76,292 KB
testcase_29 AC 84 ms
76,044 KB
testcase_30 AC 89 ms
76,044 KB
testcase_31 AC 74 ms
72,728 KB
testcase_32 WA -
testcase_33 WA -
testcase_34 AC 37 ms
53,460 KB
testcase_35 AC 35 ms
53,460 KB
testcase_36 AC 36 ms
53,460 KB
testcase_37 AC 36 ms
53,460 KB
testcase_38 AC 50 ms
63,936 KB
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 AC 87 ms
76,556 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

for i in range(N-1):
    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(i+1,N):
        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