結果

問題 No.470 Inverse S+T Problem
ユーザー Navier_BoltzmannNavier_Boltzmann
提出日時 2023-11-10 09:53:02
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 867 bytes
コンパイル時間 191 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 78,028 KB
最終ジャッジ日時 2023-11-10 09:53:06
合計ジャッジ時間 3,547 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
55,604 KB
testcase_01 AC 42 ms
55,604 KB
testcase_02 AC 43 ms
55,604 KB
testcase_03 AC 54 ms
66,656 KB
testcase_04 AC 42 ms
55,604 KB
testcase_05 AC 40 ms
55,604 KB
testcase_06 AC 63 ms
77,900 KB
testcase_07 AC 62 ms
77,900 KB
testcase_08 AC 63 ms
78,028 KB
testcase_09 AC 61 ms
71,076 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 46 ms
60,524 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 41 ms
55,604 KB
testcase_16 AC 91 ms
76,728 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 42 ms
55,604 KB
testcase_20 AC 41 ms
55,604 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 43 ms
55,604 KB
testcase_25 AC 42 ms
55,604 KB
testcase_26 AC 42 ms
55,604 KB
testcase_27 AC 41 ms
55,604 KB
testcase_28 AC 47 ms
66,236 KB
testcase_29 AC 44 ms
62,056 KB
testcase_30 AC 46 ms
64,188 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import *
from itertools import *
from functools import *
from heapq import *
import sys,math
input = sys.stdin.readline

N = int(input())
U = [input()[:-1] for _ in range(N)]
if N > 26:
    print('Impossible')
    exit()

for i in range(1<<N):
    
    
    S = []
    T = []
    
    called = defaultdict(lambda:False)
    flg = False
    for j in range(N):
        
        u = U[j]
        
        if (i>>j)&1:
            
            s = u[:2]
            t = u[2:]
        else:
            s = u[:1]
            t = u[1:]
        
        if (called[s]|called[t]):
            
            flg = True
            break
        else:
            called[s] = True
            called[t] = True
            S.append(s)
            T.append(t)
    if flg:
        continue
    for s,t in zip(S,T):
        print(s,t)
    exit()
print('Impossible')
0