結果
問題 |
No.2820 Non-Preferred IUPAC Nomenclature
|
ユーザー |
|
提出日時 | 2024-04-05 15:17:07 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 570 bytes |
コンパイル時間 | 2,190 ms |
コンパイル使用メモリ | 196,864 KB |
最終ジャッジ日時 | 2025-02-20 20:24:55 |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | TLE * 1 -- * 21 |
ソースコード
#include <bits/stdc++.h> using namespace std; int main(){ int N; cin >> N; vector<vector<int>> G(N); for (int i = 0; i < N; i++){ for (int j = 0; j < 4; j++){ string s; cin >> s; if (s != "H"){ int v = stoi(s) - 1; G[i].push_back(v); } } } auto dfs = [&](auto dfs, int v, int c) -> string { string T; if (v != 0){ T += '('; } for (int i : G[v]){ if (i == c){ continue; } T += dfs(dfs, i, v); } if (v != 0){ T += "methyl)"; } return T; }; string ans = dfs(dfs, 0, -1) + "methane"; cout << ans << endl; }