結果
問題 | No.2820 Non-Preferred IUPAC Nomenclature |
ユーザー |
![]() |
提出日時 | 2024-07-27 06:57:21 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 1,187 ms / 2,000 ms |
コード長 | 559 bytes |
コンパイル時間 | 623 ms |
コンパイル使用メモリ | 12,800 KB |
実行使用メモリ | 107,396 KB |
最終ジャッジ日時 | 2024-07-27 06:57:31 |
合計ジャッジ時間 | 9,796 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 22 |
ソースコード
import sys input = sys.stdin.readline sys.setrecursionlimit(1000000) N=int(input()) C=[input().split() for i in range(N)] E=[[] for i in range(N)] for i in range(N): for j in range(4): if C[i][j]=="H": continue x=int(C[i][j])-1 E[i].append(x) ANS=[] USE=[0]*N def dfs(x): USE[x]=1 ANS.append("(") for to in E[x]: if USE[to]==0: USE[to]=1 dfs(to) ANS.append("methyl") ANS.append(")") dfs(0) ANS=ANS[1:] ANS.pop() ANS[-1]="methane" print("".join(ANS))