結果
| 問題 |
No.2820 Non-Preferred IUPAC Nomenclature
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-07-26 22:43:35 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 242 ms / 2,000 ms |
| コード長 | 2,430 bytes |
| コンパイル時間 | 1,396 ms |
| コンパイル使用メモリ | 103,624 KB |
| 最終ジャッジ日時 | 2025-02-23 18:50:55 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 22 |
ソースコード
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <functional>
#include <cassert>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using Matrix = std::vector<std::vector<ll>>;
const int inf = 1000000000;
const ll INF = 1000000000000000000;
const ll mod = 998244353;
const ull mod_hash = (1UL << 61) - 1;
const std::vector<int> dx = {0, 1, 0, -1, 1, 1, -1, -1};
const std::vector<int> dy = {1, 0, -1, 0, 1, -1, 1, -1};
template<typename T>
struct Edge{
int from, to, id;
T cost;
Edge(int from, int to, int id, T cost): from(from), to(to), id(id), cost(cost){}
};
template<typename T>
class WeightedGraph{
public:
WeightedGraph(int N): N(N), G(N){}
void add_edge(int u, int v, int id, T cost, int zero_indexed = 0, int directed = 0){
if (!zero_indexed) {u--; v--;}
G[u].emplace_back(u, v, id, cost);
if(!directed)G[v].emplace_back(v, u, id, cost);
}
int size()const{return G.size();};
const std::vector<Edge<T>>& operator[](int i)const{return G[i];};
private:
int N;
std::vector<std::vector<Edge<T>>> G;
};
class UnweightedGraph{
public:
UnweightedGraph(int N): N(N), G(N){}
void read_edge(int zero_indexed = 0, int directed = 0){
int u, v; std::cin >> u >> v;
add_edge(u, v, zero_indexed, directed);
}
void add_edge(int u, int v, int zero_indexed = 0, int directed = 0){
if (!zero_indexed) {u--; v--;}
G[u].push_back(v);
if(!directed)G[v].push_back(u);
}
int size()const{return G.size();};
const std::vector<int>& operator[](int i)const{return G[i];};
private:
int N;
std::vector<std::vector<int>> G;
};
void dfs(UnweightedGraph &G, int n, int p, string &ans){
for(int nxt : G[n]){
if (nxt == p) continue;
ans += "(";
dfs(G, nxt, n, ans);
ans += "yl)";
}
ans += "meth";
return ;
}
int main(){
int N; cin >> N;
UnweightedGraph G(N);
for(int i = 0; i < N; i++){
for(int j = 0; j < 4; j++){
string c; cin >> c;
if (c != "H"){
int v = stoi(c) - 1;
G.add_edge(i, v, 1, 1);
}
}
}
string ans = "";
dfs(G, 0, -1, ans);
cout << ans + "ane"<< endl;
return 0;
}