結果

問題 No.548 国士無双
ユーザー rpy3cpp
提出日時 2017-07-28 23:42:33
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 616 bytes
コンパイル時間 133 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 10,624 KB
最終ジャッジ日時 2024-07-05 20:25:35
合計ジャッジ時間 1,695 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 23 WA * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

S = input().rstrip()

def is_valid(S):
    freq = [0] * 13
    for a in S:
        if a > 'm' or a < 'a':
            print("Impossible")
            return
        freq[ord(a) - ord('a')] += 1
    nzero = 0
    ntwo = 0
    t = []
    for i, f in enumerate(freq):
        if f == 0:
            nzero += 1
            t.append(chr(ord('a') + i))
        if f == 2:
            ntwo += 1
        if f >= 3:
            return False
    if (nzero == 1 and ntwo == 1):
        print(t[0])
    elif (nzero == 0 and ntwo == 0):
        print('\n'.join('abcdefghijklm'))
    else:
        print("Impossible")

is_valid(S)
0