結果

問題 No.470 Inverse S+T Problem
ユーザー lam6er
提出日時 2025-03-26 15:45:14
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 633 bytes
コンパイル時間 173 ms
コンパイル使用メモリ 81,920 KB
実行使用メモリ 52,608 KB
最終ジャッジ日時 2025-03-26 15:45:36
合計ジャッジ時間 2,940 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 18 WA * 9
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
used = set()
result = []
possible = True

for _ in range(n):
    u = input().strip()
    s1, t1 = u[0], u[1:]
    s2, t2 = u[:2], u[2]
    
    # Check first split possibility
    if s1 not in used and t1 not in used:
        used.add(s1)
        used.add(t1)
        result.append(f"{s1} {t1}")
    else:
        # Check second split possibility
        if s2 not in used and t2 not in used:
            used.add(s2)
            used.add(t2)
            result.append(f"{s2} {t2}")
        else:
            possible = False
            break

if possible:
    print('\n'.join(result))
else:
    print("Impossible")
0