#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);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
344 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
344 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
344 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
344 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
444 KB |
Output is correct |
15 |
Correct |
0 ms |
344 KB |
Output is correct |
16 |
Correct |
1 ms |
348 KB |
Output is correct |
17 |
Correct |
0 ms |
452 KB |
Output is correct |
18 |
Correct |
1 ms |
348 KB |
Output is correct |