結果
| 問題 |
No.2820 Non-Preferred IUPAC Nomenclature
|
| コンテスト | |
| ユーザー |
risujiroh
|
| 提出日時 | 2024-07-26 23:00:06 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 158 ms / 2,000 ms |
| コード長 | 704 bytes |
| コンパイル時間 | 3,332 ms |
| コンパイル使用メモリ | 250,108 KB |
| 実行使用メモリ | 16,512 KB |
| 最終ジャッジ日時 | 2024-07-26 23:00:16 |
| 合計ジャッジ時間 | 9,297 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 22 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
void Solve() {
int n;
cin >> n;
vector<vector<int>> g(n);
for (int i = 0; i < n; ++i) {
for (int _ = 4; _--;) {
cin >> ws;
if (cin.peek() == 'H') {
cin.ignore();
} else {
int j;
cin >> j;
--j;
g[i].push_back(j);
}
}
}
auto Dfs = [&](auto Dfs, int i, int p) -> void {
for (int j : g[i]) {
if (j == p) {
continue;
}
cout << '(';
Dfs(Dfs, j, i);
cout << ')';
}
cout << (p == -1 ? "methane" : "methyl");
};
Dfs(Dfs, 0, -1);
cout << '\n';
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
Solve();
}
risujiroh