結果
問題 | No.2820 Non-Preferred IUPAC Nomenclature |
ユーザー |
|
提出日時 | 2024-07-26 21:37:22 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 204 ms / 2,000 ms |
コード長 | 725 bytes |
コンパイル時間 | 2,144 ms |
コンパイル使用メモリ | 198,876 KB |
最終ジャッジ日時 | 2025-02-23 18:27:01 |
ジャッジサーバーID (参考情報) |
judge4 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 22 |
ソースコード
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); int N; cin >> N; vector<vector<int>> Graph(N); for(int i=0; i<N; i++){ for(int k=0; k<4; k++){ string s; cin >> s; if(s == "H") continue; int u = stoi(s)-1; Graph.at(u).push_back(i); } } auto dfs = [&](auto dfs,int pos,int back) -> void { for(auto to : Graph.at(pos)){ if(to == back) continue; cout << "("; dfs(dfs,to,pos); cout << ")"; } if(back == -1) cout << "methane\n"; else cout << "methyl"; }; dfs(dfs,0,-1); }