結果

問題 No.2820 Non-Preferred IUPAC Nomenclature
ユーザー kokosei
提出日時 2024-07-27 09:00:38
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 757 bytes
コンパイル時間 1,116 ms
コンパイル使用メモリ 90,256 KB
実行使用メモリ 22,592 KB
最終ジャッジ日時 2024-07-27 09:00:43
合計ジャッジ時間 4,496 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 4
other AC * 1 WA * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
using namespace std;
using ll = long long;

int N;
vector<int> G[202020];
void dfs(int v, int p, string& ans){
    for(int nv : G[v]){
        if(nv == p)continue;
        ans += "(";
        dfs(nv, v, ans);
        ans.erase(ans.end() - 3, ans.end());
        ans += "yl)";
    }
    ans += "methane";
}
int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    cin >> N;
    for(int i = 0;i < N;i++){
        for(int j = 0;j < 4;j++){
            string c; cin >> c;
            if(c == "H")continue;
            int v = stoi(c) - 1;
            cout << v << endl;
            G[i].push_back(v);
        }
    }
    string ans = "";
    dfs(0, -1, ans);
    cout << ans << endl;
    return 0;
}
0