結果
問題 |
No.2820 Non-Preferred IUPAC Nomenclature
|
ユーザー |
![]() |
提出日時 | 2024-07-26 22:35:38 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 766 bytes |
コンパイル時間 | 2,239 ms |
コンパイル使用メモリ | 199,004 KB |
最終ジャッジ日時 | 2025-02-23 18:49:10 |
ジャッジサーバーID (参考情報) |
judge3 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | TLE * 1 -- * 21 |
ソースコード
#define NDEBUG #include <bits/stdc++.h> using namespace std; vector<vector<int>> G; bool vis[200000]; string dfs(int const u) { vis[u] = true; string ret; for (int const v : G[u]) if (not vis[v]) { string sub{dfs(v)}; for (int i=0; i < 3; ++i) sub.pop_back(); ret += "("; ret += sub; ret += "yl)"; } ret += "methane"; fprintf(stderr, "dfs(%d) -> %s\n", u, ret.c_str()); return ret; } int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); int N; cin >> N; G.resize(N); for (int u=0; u < N; ++u) for (int i=0; i < 4; ++i) { string C; cin >> C; if (C != "H") { int const v{stoi(C) - 1}; G[u].push_back(v); } } cout << dfs(0) << endl; }