結果

問題 No.2820 Non-Preferred IUPAC Nomenclature
ユーザー みどりむし🦠
提出日時 2024-06-19 12:04:03
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 110 ms / 2,000 ms
コード長 920 bytes
コンパイル時間 1,137 ms
コンパイル使用メモリ 103,004 KB
実行使用メモリ 25,252 KB
最終ジャッジ日時 2024-07-26 16:28:08
合計ジャッジ時間 5,959 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdint>
#include <iostream>
#include <ranges>
#include <vector>
#include <string>
#include <array>

signed main() {
    int n; std::cin >> n;

    std::vector<std::vector<int>> tree(n);

    for(const auto i : std::views::iota(0, n)) {
        for([[maybe_unused]] const auto _ : 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, const auto v, const auto p) -> void {
        for(const auto nv : tree[v]) {
            if(nv == p) continue;

            ans += "(";

            dfs(dfs, nv, v);

            ans += "yl)";
        }

        ans += "meth";
    };

    dfs(dfs, 0, -1);

    std::cout << ans + "ane\n";
}

__attribute__((constructor)) inline void fast_io() { std::ios::sync_with_stdio(false), std::cin.tie(nullptr); }
0