結果

問題 No.2820 Non-Preferred IUPAC Nomenclature
ユーザー titiatitia
提出日時 2024-07-27 03:50:47
言語 PyPy3
(7.3.15)
結果
MLE  
実行時間 -
コード長 555 bytes
コンパイル時間 567 ms
コンパイル使用メモリ 82,408 KB
実行使用メモリ 660,276 KB
最終ジャッジ日時 2024-07-27 03:50:53
合計ジャッジ時間 5,086 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 45 ms
62,508 KB
testcase_01 AC 50 ms
56,940 KB
testcase_02 AC 45 ms
56,652 KB
testcase_03 AC 44 ms
55,616 KB
testcase_04 MLE -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

sys.setrecursionlimit(2000200)

N=int(input())
C=[input().split() for i in range(N)]

USE=[0]*N

from functools import lru_cache
@lru_cache(maxsize=None)
def dfs(x):
    USE[x]=1
    ANS=[]
    for i in range(4):
        if C[x][i]=="H":
            continue
        k=int(C[x][i])-1
        
        if USE[k]==1:
            continue

        ANS.append("(")
        ANS+=dfs(k)
        ANS.append(")")

    ANS.append("methyl")

    #print(ANS)

    return ANS

ANS=dfs(0)

ANS[-1]="methane"

print("".join(ANS))
0