結果

問題 No.2820 Non-Preferred IUPAC Nomenclature
ユーザー anonymouslyanonymously
提出日時 2024-07-26 23:26:34
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 256 ms / 2,000 ms
コード長 894 bytes
コンパイル時間 2,287 ms
コンパイル使用メモリ 206,436 KB
実行使用メモリ 21,492 KB
最終ジャッジ日時 2024-07-26 23:26:42
合計ジャッジ時間 8,100 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 256 ms
21,492 KB
testcase_05 AC 123 ms
13,824 KB
testcase_06 AC 216 ms
19,616 KB
testcase_07 AC 23 ms
5,376 KB
testcase_08 AC 11 ms
5,376 KB
testcase_09 AC 18 ms
5,376 KB
testcase_10 AC 4 ms
5,376 KB
testcase_11 AC 3 ms
5,376 KB
testcase_12 AC 3 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 2 ms
5,376 KB
testcase_15 AC 2 ms
5,376 KB
testcase_16 AC 2 ms
5,376 KB
testcase_17 AC 2 ms
5,376 KB
testcase_18 AC 2 ms
5,376 KB
testcase_19 AC 2 ms
5,376 KB
testcase_20 AC 2 ms
5,376 KB
testcase_21 AC 2 ms
5,376 KB
testcase_22 AC 2 ms
5,376 KB
testcase_23 AC 2 ms
5,376 KB
testcase_24 AC 2 ms
5,376 KB
testcase_25 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define NDEBUG

void 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 NDEBUG
	clock_t clockt = clock();
#endif
	int n;
#ifdef NDEBUG
	cin >> n;
#else
	n = 20000;
#endif
	vector<vector<int>> C(n);
	for (int i = 0; i < n; i++) {
#ifdef NDEBUG
		for (int j = 0; j < 4; j++) {
			string s;
			cin >> s;
			if (s != "H") {
				C[i].push_back(stoi(s) - 1);
			}
		}
#else
		if (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 NDEBUG
	cerr << "took " << (double) (clock() - clockt) / CLOCKS_PER_SEC << " sec." << endl;
#endif
	return 0;
}
0