結果
問題 |
No.2820 Non-Preferred IUPAC Nomenclature
|
ユーザー |
|
提出日時 | 2024-07-26 23:35:36 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 757 bytes |
コンパイル時間 | 3,239 ms |
コンパイル使用メモリ | 252,236 KB |
実行使用メモリ | 813,884 KB |
最終ジャッジ日時 | 2024-07-26 23:35:45 |
合計ジャッジ時間 | 7,269 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | WA * 4 |
other | MLE * 1 -- * 21 |
ソースコード
#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 v = stoi(S); v--; G[i].push_back(v); G[v].push_back(i); } } string ans; auto rec = [&](auto f, int v, int p=-1) -> void { for(int nv : G[v]) { if(nv == p) continue; ans += "("; f(f, nv, v); ans += ")"; } ans += "methyl"; }; rec(rec, 0); ans.pop_back(); ans.pop_back(); ans += "ane"; cout << ans << endl; return 0; }