結果
問題 |
No.2820 Non-Preferred IUPAC Nomenclature
|
ユーザー |
![]() |
提出日時 | 2024-07-27 04:14:59 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 679 bytes |
コンパイル時間 | 610 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 77,692 KB |
最終ジャッジ日時 | 2024-07-27 04:15:05 |
合計ジャッジ時間 | 5,313 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 WA * 1 |
other | TLE * 1 -- * 21 |
ソースコード
import sys input = sys.stdin.readline sys.setrecursionlimit(2000200) N=int(input()) C=[input().split() for i in range(N)] USE=[0]*N 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 X=dfs(k) if ANS==[] or len(X)<len(ANS): ANS.append("(") ANS+=X ANS.append(")") else: X.append("(") X+=ANS X.append(")") ANS=X ANS.append("methyl") #print(ANS) return ANS ANS=dfs(0) ANS[-1]="methane" print("".join(ANS))