結果
問題 | No.2820 Non-Preferred IUPAC Nomenclature |
ユーザー |
|
提出日時 | 2024-07-26 23:26:34 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 251 ms / 2,000 ms |
コード長 | 894 bytes |
コンパイル時間 | 3,394 ms |
コンパイル使用メモリ | 200,148 KB |
最終ジャッジ日時 | 2025-02-23 18:55:41 |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 22 |
ソースコード
#include <bits/stdc++.h>using namespace std;#define NDEBUGvoid dfs(const vector<vector<int>> &G, int v, vector<bool> &visited) {visited[v] = true;string str;for (int u : G[v]) {if (!visited[u]) {cout << "(";dfs(G, u, visited);cout << "methyl)";}}}int main() {#ifndef NDEBUGclock_t clockt = clock();#endifint n;#ifdef NDEBUGcin >> n;#elsen = 20000;#endifvector<vector<int>> C(n);for (int i = 0; i < n; i++) {#ifdef NDEBUGfor (int j = 0; j < 4; j++) {string s;cin >> s;if (s != "H") {C[i].push_back(stoi(s) - 1);}}#elseif (i > 0)C[i].push_back(i - 1);if (i < n - 1)C[i].push_back(i + 1);#endif}vector<bool> visited(n, false);dfs(C, 0, visited);cout << "methane" << endl;#ifndef NDEBUGcerr << "took " << (double) (clock() - clockt) / CLOCKS_PER_SEC << " sec." << endl;#endifreturn 0;}