結果
問題 |
No.2820 Non-Preferred IUPAC Nomenclature
|
ユーザー |
|
提出日時 | 2024-07-27 19:37:40 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 128 ms / 2,000 ms |
コード長 | 686 bytes |
コンパイル時間 | 2,060 ms |
コンパイル使用メモリ | 199,888 KB |
最終ジャッジ日時 | 2025-02-23 19:18:49 |
ジャッジサーバーID (参考情報) |
judge2 / 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<vector<int>> g(n); string s; for(int i = 0; i < n; i++){ for(int j = 0; j < 4; j++){ cin >> s; if(s[0] != 'H'){ int v = stoi(s) - 1; g[i].emplace_back(v); } } } auto dfs = [&](auto dfs, int v, int p) -> void { for(auto &&u : g[v]){ if(u == p) continue; cout << '('; dfs(dfs, u, v); cout << ')'; } cout << (p != -1 ? "methyl" : "methane\n"); }; dfs(dfs, 0, -1); }