結果

問題 No.2820 Non-Preferred IUPAC Nomenclature
ユーザー flippergo
提出日時 2025-03-17 17:25:58
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 550 bytes
コンパイル時間 515 ms
コンパイル使用メモリ 82,360 KB
実行使用メモリ 152,320 KB
最終ジャッジ日時 2025-03-17 17:26:05
合計ジャッジ時間 6,243 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 16 RE * 6
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import deque
N = int(input())
G = {i:[] for i in range(1,N+1)}
Num =set({str(i):i for i in range(1,N+1)})
for i in range(1,N+1):
    a,b,c,d = input().split()
    if a in Num:
        G[i].append(int(a))
    if b in Num:
        G[i].append(int(b))
    if c in Num:
        G[i].append(int(c))
    if d in Num:
        G[i].append(int(d))
ans = deque(["methane"])
def dfs(i,pi):
    for j in G[i]:
        if j==pi:continue
        ans.appendleft(("methyl)"))
        dfs(j,i)
        ans.appendleft("(")
dfs(1,0)
print("".join(ans))
0