結果
| 問題 | No.2820 Non-Preferred IUPAC Nomenclature |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-07-26 22:32:56 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
AC
|
| 実行時間 | 807 ms / 2,000 ms |
| コード長 | 540 bytes |
| 記録 | |
| コンパイル時間 | 125 ms |
| コンパイル使用メモリ | 85,168 KB |
| 実行使用メモリ | 253,496 KB |
| 最終ジャッジ日時 | 2026-04-03 18:43:51 |
| 合計ジャッジ時間 | 6,418 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge5_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 22 |
ソースコード
from collections import defaultdict
import sys
sys.setrecursionlimit(500000)
ans=[]
check=set([1])
path=defaultdict(list)
def dfs(i):
if i!=1:
ans.append("(")
for j in path[i]:
if j not in check:
check.add(j)
dfs(j)
if i!=1:
ans.append("methyl)")
else:
ans.append("methane")
N=int(input())
for i in range(1,N+1):
a=list(map(str,input().split()))
for j in range(4):
if a[j]!="H" and i<int(a[j]):
path[i].append(int(a[j]))
path[int(a[j])].append(i)
dfs(1)
print("".join(ans))