Submission #862375

#TimeUsernameProblemLanguageResultExecution timeMemory
862375TAhmed33Kaučuk (COCI21_kaucuk)C++98
50 / 50
1 ms452 KiB
#include <bits/stdc++.h> #pragma GCC optimize ("Ofast") using namespace std; string name[101]; vector <int> adj[101]; void dfs (int pos, int a, int b, int c, int dep = 0) { if (pos != 0) { cout << a; if (dep >= 2) cout << '.' << b; if (dep == 3) cout << '.' << c; cout << " " << name[pos] << '\n'; } int cnt = 0; for (auto j : adj[pos]) { cnt += 1; if (dep == 0) { dfs(j, cnt, 0, 0, dep + 1); } else if (dep == 1) { dfs(j, a, cnt, 0, dep + 1); } else { dfs(j, a, b, cnt, dep + 1); } } } int main () { int n; cin >> n; vector <int> x = {0}; map <string, int> p = { {"section", 1}, {"subsection", 2}, {"subsubsection", 3} }; for (int i = 1; i <= n; i++) { string s; cin >> s; cin >> name[i]; while ((int)x.size() > p[s]) { x.pop_back(); } adj[x.back()].push_back(i); x.push_back(i); } dfs(0, 0, 0, 0); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...