結果
問題 | No.2820 Non-Preferred IUPAC Nomenclature |
ユーザー |
![]() |
提出日時 | 2024-04-06 11:58:54 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 128 ms / 2,000 ms |
コード長 | 959 bytes |
コンパイル時間 | 1,066 ms |
コンパイル使用メモリ | 103,512 KB |
実行使用メモリ | 24,664 KB |
最終ジャッジ日時 | 2024-07-26 16:27:36 |
合計ジャッジ時間 | 6,441 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 22 |
ソースコード
#include <cstdint> #include <iostream> #include <ranges> #include <vector> #include <string> #include <array> void solve() { int n; std::cin >> n; std::vector<std::vector<int>> tree(n); for(const int i : std::views::iota(0, n)) { for([[maybe_unused]] const int _ : std::views::iota(0, 4)) { std::string c; std::cin >> c; if(c == "H") continue; tree[i].emplace_back(std::stoi(c) - 1); } } std::string ans; auto dfs = [&](auto&& dfs, int v, int p) -> void { for(const int nv : tree[v]) { if(nv < 0 || nv == p) continue; ans += "("; dfs(dfs, nv, v); ans += "yl)"; } ans += "meth"; }; dfs(dfs, n / 2, -1); std::cout << ans + "ane\n"; } int main() { solve(); return 0; } __attribute__((constructor)) inline void fast_io() { std::ios::sync_with_stdio(false), std::cin.tie(nullptr); }