結果
問題 | No.2820 Non-Preferred IUPAC Nomenclature |
ユーザー | detteiuu |
提出日時 | 2024-07-26 22:28:45 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 679 ms / 2,000 ms |
コード長 | 1,122 bytes |
コンパイル時間 | 1,013 ms |
コンパイル使用メモリ | 81,948 KB |
実行使用メモリ | 229,432 KB |
最終ジャッジ日時 | 2024-07-26 22:28:55 |
合計ジャッジ時間 | 8,919 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 41 ms
55,252 KB |
testcase_01 | AC | 43 ms
54,344 KB |
testcase_02 | AC | 43 ms
54,488 KB |
testcase_03 | AC | 43 ms
55,048 KB |
testcase_04 | AC | 679 ms
229,432 KB |
testcase_05 | AC | 369 ms
147,472 KB |
testcase_06 | AC | 569 ms
193,020 KB |
testcase_07 | AC | 141 ms
90,440 KB |
testcase_08 | AC | 117 ms
81,548 KB |
testcase_09 | AC | 128 ms
86,468 KB |
testcase_10 | AC | 101 ms
78,172 KB |
testcase_11 | AC | 77 ms
74,348 KB |
testcase_12 | AC | 90 ms
77,544 KB |
testcase_13 | AC | 45 ms
55,992 KB |
testcase_14 | AC | 43 ms
55,604 KB |
testcase_15 | AC | 46 ms
56,324 KB |
testcase_16 | AC | 46 ms
56,156 KB |
testcase_17 | AC | 43 ms
55,696 KB |
testcase_18 | AC | 44 ms
56,524 KB |
testcase_19 | AC | 42 ms
54,792 KB |
testcase_20 | AC | 42 ms
55,316 KB |
testcase_21 | AC | 42 ms
54,488 KB |
testcase_22 | AC | 42 ms
56,052 KB |
testcase_23 | AC | 41 ms
54,732 KB |
testcase_24 | AC | 42 ms
54,740 KB |
testcase_25 | AC | 41 ms
55,512 KB |
ソースコード
from types import GeneratorType from collections import deque def bootstrap(f, stack=[]): def wrappedfunc(*args, **kwargs): if stack: return f(*args, **kwargs) to = f(*args, **kwargs) while True: if type(to) is GeneratorType: stack.append(to) to = next(to) else: stack.pop() if not stack: break to = stack[-1].send(to) return to return wrappedfunc N = int(input()) C = [list(input().split()) for _ in range(N)] G = [[] for _ in range(N)] for i in range(N): for j in range(4): if C[i][j] != "H": G[i].append(int(C[i][j])-1) @bootstrap def dfs(n): visited[n] = True for v in G[n]: if not visited[v]: A.append("(") yield dfs(v) A.append(")") yield visited = [False]*N A = [] dfs(0) ans = [] for i in range(len(A)): if A[i] == "(": ans.append("(") else: ans.append("methyl") ans.append(")") ans.append("methane") print("".join(ans))