結果
| 問題 |
No.2820 Non-Preferred IUPAC Nomenclature
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-04-05 15:28:58 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 221 ms / 2,000 ms |
| コード長 | 550 bytes |
| コンパイル時間 | 2,246 ms |
| コンパイル使用メモリ | 198,904 KB |
| 最終ジャッジ日時 | 2025-02-20 20:25:24 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 22 |
ソースコード
#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"){
int v = stoi(s) - 1;
G[i].push_back(v);
}
}
}
string ans;
auto dfs = [&](auto dfs, int v, int c) -> void {
if (v != 0){
ans += '(';
}
for (int i : G[v]){
if (i == c){
continue;
}
dfs(dfs, i, v);
}
if (v != 0){
ans += "methyl)";
}
};
dfs(dfs, 0, -1);
ans += "methane";
cout << ans << endl;
}