結果

問題 No.2820 Non-Preferred IUPAC Nomenclature
ユーザー れもん丸
提出日時 2024-07-26 22:00:05
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
RE  
実行時間 -
コード長 1,362 bytes
コンパイル時間 2,008 ms
コンパイル使用メモリ 205,116 KB
最終ジャッジ日時 2025-02-23 18:37:28
ジャッジサーバーID
(参考情報)
judge4 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3 RE * 1
other WA * 8 RE * 8 TLE * 3 -- * 3
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (long long i = 0; i < n; ++i)
using ll = long long;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 998244353;
constexpr bool debug = false;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
//---------------------------------//

string GetName(vector<set<int>> Alkane, int root){
    string name = "";

    vector<set<int>> ChildAlkane = Alkane;
    ChildAlkane[root].clear();
    for (int child : Alkane[root]){
        ChildAlkane[child].erase(root);
    }

    for (int child : Alkane[root]){
        string ChildName = GetName(ChildAlkane, child);
        for (int cnt = 0; cnt < 3; cnt++) ChildName.pop_back();
        name += "(" + ChildName + "yl)";
    }

    name += "methane";

    return name;
}

int main(){
    int N;
    cin >> N;

    vector<set<int>> Alkane(N, set<int>());
    for (int i = 0; i < N; ++i){
        for (int j = 0; j < 4; ++j){
            char c;
            cin >> c;
            if (c != 'H'){
                Alkane[i].insert(c-'1');
            }
        }
    }

    cout << GetName(Alkane, 0) << endl;

    return 0;
}
0