結果
問題 |
No.2820 Non-Preferred IUPAC Nomenclature
|
ユーザー |
|
提出日時 | 2024-07-27 19:43:39 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 123 ms / 2,000 ms |
コード長 | 594 bytes |
コンパイル時間 | 2,113 ms |
コンパイル使用メモリ | 195,656 KB |
最終ジャッジ日時 | 2025-02-23 19:19:01 |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 22 |
ソースコード
#include <bits/stdc++.h> using namespace std; int main(){ ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; vector<array<string, 4>> g(n); for(auto &&ary : g){ for(auto &&ss : ary) cin >> ss; } auto dfs = [&](auto dfs, int v, int p) -> void { for(auto &&us : g[v]){ if (us[0] == 'H') continue; int u = stoi(us) - 1; if (u == p) continue; cout << '('; dfs(dfs, u, v); cout << ')'; } cout << (v ? "methyl" : "methane\n"); }; dfs(dfs, 0, -1); }