結果

問題 No.2820 Non-Preferred IUPAC Nomenclature
ユーザー hiromi_ayasehiromi_ayase
提出日時 2024-07-26 23:11:04
言語 C++23
(gcc 12.3.0 + boost 1.83.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
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 1 ms
6,944 KB
testcase_03 AC 1 ms
6,944 KB
testcase_04 AC 176 ms
56,656 KB
testcase_05 AC 83 ms
31,528 KB
testcase_06 AC 143 ms
37,080 KB
testcase_07 AC 17 ms
6,984 KB
testcase_08 AC 9 ms
6,944 KB
testcase_09 AC 13 ms
6,940 KB
testcase_10 AC 3 ms
6,944 KB
testcase_11 AC 2 ms
6,944 KB
testcase_12 AC 3 ms
6,944 KB
testcase_13 AC 2 ms
6,944 KB
testcase_14 AC 2 ms
6,944 KB
testcase_15 AC 2 ms
6,940 KB
testcase_16 AC 2 ms
6,944 KB
testcase_17 AC 2 ms
6,944 KB
testcase_18 AC 2 ms
6,940 KB
testcase_19 AC 2 ms
6,940 KB
testcase_20 AC 1 ms
6,944 KB
testcase_21 AC 2 ms
6,940 KB
testcase_22 AC 2 ms
6,940 KB
testcase_23 AC 2 ms
6,940 KB
testcase_24 AC 2 ms
6,940 KB
testcase_25 AC 1 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0