結果
問題 | No.2820 Non-Preferred IUPAC Nomenclature |
ユーザー |
|
提出日時 | 2025-02-12 11:16:20 |
言語 | PyPy3 (7.3.15) |
結果 |
MLE
|
実行時間 | - |
コード長 | 644 bytes |
コンパイル時間 | 261 ms |
コンパイル使用メモリ | 82,176 KB |
実行使用メモリ | 700,760 KB |
最終ジャッジ日時 | 2025-02-12 11:16:38 |
合計ジャッジ時間 | 16,352 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 MLE * 2 |
other | AC * 19 TLE * 3 |
ソースコード
import syssys.setrecursionlimit(10 ** 8)from collections import dequen=int(input())if n==1:print("methane")exit()R=[[] for _ in range(n+1)]for i in range(1,n+1):A=input().split()for j in A:if j!="H":R[i].append(int(j))R[int(j)].append(i)for i in range(n+1):R[i]=list(set(R[i]))F=[0]*(n+1)def dfs(x):que=deque()que.append("methyl")F[x]=1for i in R[x]:if F[i]==0:que.append(")")que.extend(dfs(i))que.append("(")return queans=list(dfs(1))ans=ans[::-1]ans.pop()ans.append("methane")print("".join(ans))