結果

問題 No.2820 Non-Preferred IUPAC Nomenclature
ユーザー coindarw
提出日時 2024-07-26 22:09:30
言語 C++23
(gcc 15.3.0 + boost 1.92.0 + ACL)
コンパイル:
g++-15 -O2 -fplugin=/usr/lib/yukicoder/noavx512-gcc15.so -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 156 ms / 2,000 ms
+ 254µs
コード長 719 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,228 ms
コンパイル使用メモリ 346,360 KB
実行使用メモリ 20,856 KB
最終ジャッジ日時 2026-11-01 19:12:58
合計ジャッジ時間 8,529 ms
ジャッジサーバーID
(参考情報)
judge7_0 / judge4_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#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") {
                continue;
            }
            int x = stoi(s) - 1;
            G[i].push_back(x);
        }
    }
    vector<bool> seen(n, false);
    auto dfs = [&](auto dfs, int u) -> void {
        seen.at(u) = true;
        if (u) cout << "(";
        for (const auto &to : G.at(u)) {
            if (seen.at(to)) continue;
            dfs(dfs, to);
        }
        if (u) cout << "methyl)";
    };
    dfs(dfs, 0);
    cout << "methane" << endl;
}
0