結果
| 問題 |
No.470 Inverse S+T Problem
|
| コンテスト | |
| ユーザー |
gew1fw
|
| 提出日時 | 2025-06-12 19:40:52 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 922 bytes |
| コンパイル時間 | 170 ms |
| コンパイル使用メモリ | 82,148 KB |
| 実行使用メモリ | 66,452 KB |
| 最終ジャッジ日時 | 2025-06-12 19:41:01 |
| 合計ジャッジ時間 | 2,881 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 18 WA * 9 |
ソースコード
def main():
import sys
input = sys.stdin.read().split()
n = int(input[0])
us = input[1:n+1]
used = set()
result = []
possible = True
for u in us:
if len(u) != 3:
possible = False
break
# Split options
s1 = u[0]
t1 = u[1:3]
s2 = u[0:2]
t2 = u[2]
# Try split1
if s1 not in used and t1 not in used:
used.add(s1)
used.add(t1)
result.append((s1, t1))
continue
# Try split2
if s2 not in used and t2 not in used:
used.add(s2)
used.add(t2)
result.append((s2, t2))
continue
# If neither works
possible = False
break
if not possible:
print("Impossible")
else:
for s, t in result:
print(f"{s} {t}")
if __name__ == "__main__":
main()
gew1fw