結果

問題 No.2820 Non-Preferred IUPAC Nomenclature
ユーザー nikoro256
提出日時 2024-07-26 22:21:54
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 610 bytes
コンパイル時間 373 ms
コンパイル使用メモリ 82,220 KB
実行使用メモリ 414,112 KB
最終ジャッジ日時 2024-07-26 22:22:07
合計ジャッジ時間 11,822 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 21 TLE * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
from collections import deque

sys.setrecursionlimit(4 * 10**5)

N = int(input())
C = []
for _ in range(N):
    C_d = list(map(str, input().split()))
    C.append(C_d)

ans = deque()


def dfs(parent, pos):
    global ans
    for e in C[pos]:
        if e != "H" and e != str(parent + 1):
            e = int(e) - 1
            ans.append("(")
            dfs(pos, e)
            for i in range(3):
                ans.pop()
            ans.append("y")
            ans.append("l")
            ans.append(")")
    for s in "methane":
        ans.append(s)
    return


dfs(-1, 0)
print("".join(ans))
0