結果
| 問題 |
No.2820 Non-Preferred IUPAC Nomenclature
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-07-26 22:32:58 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,017 bytes |
| コンパイル時間 | 1,951 ms |
| コンパイル使用メモリ | 199,632 KB |
| 最終ジャッジ日時 | 2025-02-23 18:48:18 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | TLE * 1 -- * 21 |
ソースコード
#include <bits/stdc++.h>
//#include <atcoder/all>
using ll = long long;
const int MOD = 1000000007;
const int Mod = 998244353;
const int MAX = 1000000005;
const long long INF = 1000000000000000005LL;
using namespace std;
//using namespace atcoder;
string dfs(int v, int p, vector<vector<int>>& G) {
string ret;
for (int& nv : G[v]) {
if (nv == p) continue;
string response = dfs(nv, v, G);
for (int i = 0; i < 3; i++) response.pop_back();
ret += "(";
ret += response;
ret += "yl)";
}
ret += "methane";
return ret;
}
int main() {
ios::sync_with_stdio(0); cin.tie();
int N;
cin >> N;
vector<vector<int>> G(N);
for (int i = 0; i < N; i++) {
vector<string> L(4);
for (int j = 0; j < 4; j++) cin >> L[j];
for (int j = 0; j < 4; j++) {
if (L[j] != "H") {
int v = stoi(L[j]) - 1;
G[i].push_back(v);
}
}
}
cout << dfs(0, -1, G) << endl;
}