結果
問題 |
No.2820 Non-Preferred IUPAC Nomenclature
|
ユーザー |
|
提出日時 | 2024-07-26 22:09:44 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 841 bytes |
コンパイル時間 | 2,327 ms |
コンパイル使用メモリ | 94,448 KB |
実行使用メモリ | 31,200 KB |
最終ジャッジ日時 | 2024-07-26 22:09:50 |
合計ジャッジ時間 | 5,084 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | TLE * 1 -- * 21 |
ソースコード
#include <iostream> #include <vector> #include <string> using namespace std; int main () { int N; cin >> N; vector<vector<int>> graph(N); for (int i = 0; i < N; i++) { for (int j = 0; j < 4; j++) { string str; cin >> str; int to; try { to = stoi(str) - 1; } catch (...) { continue; } graph[i].push_back(to); } } auto dfs = [&] (auto self, int pos, int par) -> string { string res = ""; for (auto nex: graph[pos]) { if (nex == par) continue; auto name = self(self, nex, pos); res += "(" + name.substr(0, name.size() - 3) + "yl)"; } res += "methane"; return res; }; cout << dfs(dfs, 0, -1) << "\n"; }