結果

問題 No.548 国士無双
ユーザー rpy3cpprpy3cpp
提出日時 2017-07-28 23:42:33
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 616 bytes
コンパイル時間 819 ms
コンパイル使用メモリ 10,836 KB
実行使用メモリ 7,948 KB
最終ジャッジ日時 2023-09-19 08:36:52
合計ジャッジ時間 1,848 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
7,760 KB
testcase_01 AC 16 ms
7,740 KB
testcase_02 AC 17 ms
7,736 KB
testcase_03 AC 17 ms
7,944 KB
testcase_04 AC 16 ms
7,796 KB
testcase_05 AC 17 ms
7,812 KB
testcase_06 AC 16 ms
7,924 KB
testcase_07 AC 17 ms
7,856 KB
testcase_08 AC 16 ms
7,884 KB
testcase_09 AC 16 ms
7,724 KB
testcase_10 AC 16 ms
7,728 KB
testcase_11 AC 16 ms
7,716 KB
testcase_12 AC 17 ms
7,796 KB
testcase_13 AC 17 ms
7,788 KB
testcase_14 AC 16 ms
7,740 KB
testcase_15 AC 17 ms
7,732 KB
testcase_16 AC 17 ms
7,840 KB
testcase_17 AC 16 ms
7,884 KB
testcase_18 AC 16 ms
7,716 KB
testcase_19 AC 17 ms
7,840 KB
testcase_20 AC 17 ms
7,948 KB
testcase_21 AC 16 ms
7,748 KB
testcase_22 WA -
testcase_23 AC 16 ms
7,856 KB
権限があれば一括ダウンロードができます

ソースコード

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