結果
| 問題 | No.2820 Non-Preferred IUPAC Nomenclature |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-07-27 19:43:39 |
| 言語 | C++17 (gcc 15.2.0 + boost 1.90.0) |
| 結果 |
AC
|
| 実行時間 | 84 ms / 2,000 ms |
| コード長 | 594 bytes |
| 記録 | |
| コンパイル時間 | 1,095 ms |
| コンパイル使用メモリ | 213,224 KB |
| 実行使用メモリ | 35,632 KB |
| 最終ジャッジ日時 | 2026-07-05 08:51:45 |
| 合計ジャッジ時間 | 4,862 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 22 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
int n;
cin >> n;
vector<array<string, 4>> g(n);
for(auto &&ary : g){
for(auto &&ss : ary) cin >> ss;
}
auto dfs = [&](auto dfs, int v, int p) -> void {
for(auto &&us : g[v]){
if (us[0] == 'H') continue;
int u = stoi(us) - 1;
if (u == p) continue;
cout << '(';
dfs(dfs, u, v);
cout << ')';
}
cout << (v ? "methyl" : "methane\n");
};
dfs(dfs, 0, -1);
}