結果

問題 No.587 七対子
ユーザー lam6er
提出日時 2025-03-20 18:59:09
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 39 ms / 2,000 ms
コード長 566 bytes
コンパイル時間 179 ms
コンパイル使用メモリ 81,888 KB
実行使用メモリ 54,072 KB
最終ジャッジ日時 2025-03-20 19:00:00
合計ジャッジ時間 2,477 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 35
権限があれば一括ダウンロードができます

ソースコード

diff #

s = input().strip()
counts = [0] * 26

for c in s:
    counts[ord(c) - ord('a')] += 1

# Check if any character appears more than twice
if any(c > 2 for c in counts):
    print("Impossible")
else:
    k = sum(1 for c in counts if c == 2)
    m = sum(1 for c in counts if c == 1)
    total_non_zero = k + m
    
    if k == 6 and m == 1 and total_non_zero == 7:
        # Find the character that occurs once
        for i in range(26):
            if counts[i] == 1:
                print(chr(ord('a') + i))
                break
    else:
        print("Impossible")
0