結果

問題 No.2820 Non-Preferred IUPAC Nomenclature
ユーザー Nichi10pNichi10p
提出日時 2024-07-26 22:35:38
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 766 bytes
コンパイル時間 2,462 ms
コンパイル使用メモリ 206,188 KB
実行使用メモリ 25,884 KB
最終ジャッジ日時 2024-07-26 22:35:46
合計ジャッジ時間 7,361 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
25,884 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 TLE -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

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

vector<vector<int>> G;
bool vis[200000];

string dfs(int const u) {
  vis[u] = true;
  string ret;
  for (int const v : G[u])
    if (not vis[v]) {
      string sub{dfs(v)};
      for (int i=0; i < 3; ++i)
        sub.pop_back();
      ret += "(";
      ret += sub;
      ret += "yl)";
    }
  ret += "methane";
  fprintf(stderr, "dfs(%d) -> %s\n", u, ret.c_str());
  return ret;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);

  int N;
  cin >> N;
  G.resize(N);
  for (int u=0; u < N; ++u)
    for (int i=0; i < 4; ++i) {
      string C;
      cin >> C;
      if (C != "H") {
        int const v{stoi(C) - 1};
        G[u].push_back(v);
      }
    }

  cout << dfs(0) << endl;
}
0