結果
| 問題 |
No.2820 Non-Preferred IUPAC Nomenclature
|
| コンテスト | |
| ユーザー |
hiromi_ayase
|
| 提出日時 | 2024-07-26 23:11:04 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 176 ms / 2,000 ms |
| コード長 | 1,246 bytes |
| コンパイル時間 | 5,461 ms |
| コンパイル使用メモリ | 314,368 KB |
| 実行使用メモリ | 56,656 KB |
| 最終ジャッジ日時 | 2024-07-26 23:11:16 |
| 合計ジャッジ時間 | 11,051 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 22 |
ソースコード
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using i32 = int;
using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;
#define FAST_IO \
ios::sync_with_stdio(false); \
cin.tie(0);
const i64 INF = 1001001001001001001;
using Modint = atcoder::static_modint<998244353>;
void dfs(int v, vector<vector<int>> &G, vector<bool> &visited, vector<string> &ret) {
visited[v] = true;
for (int u : G[v]) {
if (visited[u]) continue;
ret.push_back("(");
dfs(u, G, visited, ret);
ret.push_back(")");
}
ret.push_back("methyl");
}
int main() {
FAST_IO
auto ans = 0LL;
int N;
cin >> N;
vector<vector<int>> G(N);
for (int i = 0; i < N; i++) {
string C1, C2, C3, C4;
cin >> C1 >> C2 >> C3 >> C4;
if (C1 != "H") {
G[i].push_back(stoi(C1) - 1);
}
if (C2 != "H") {
G[i].push_back(stoi(C2) - 1);
}
if (C3 != "H") {
G[i].push_back(stoi(C3) - 1);
}
if (C4 != "H") {
G[i].push_back(stoi(C4) - 1);
}
}
auto visited = vector<bool>(N, false);
vector<string> ret;
dfs(0, G, visited, ret);
ret.pop_back();
ret.push_back("methane");
for (auto v : ret) {
cout << v;
}
cout << endl;
}
hiromi_ayase