#include<bits/stdc++.h>
using namespace std;
int main(){
int n , m = 0 , l = 0 , r = 0 , t , e , i = 1;
string s = "section" , f = "subsection" , d = "subsubsection" , o , p;
cin >> n;
while(n > 0){
cin >> o >> p;
if(o == s){
m++;
}
if(m > e){
l = 0;
r = 0;
}
if(m > e){
l = 0;
r = 0;
}
else if(o == f){
l++;
}
if(l > t){
r = 0;
}
if(o == d){
r++;
}
if(m > 0 && l > 0 && r > 0){
cout << m << '.' << l << '.' << r << ' ' << p;
}
if(m > 0 && l == 0 && r == 0){
cout << m << ' ' << p << endl;
}
if(m > 0 && l > 0 && r == 0){
cout << m << '.' << l << ' ' << p << endl;
}
if(m > 0 && l == 0 && r > 0){
cout << m << "." << p << endl;
}
if(m == 0 && l > 0 && r == 0){
cout << l << " " << p << endl;
}
if(m == 0 && l > 0 && r > 0){
cout << l << "." << r << " " << endl;
}
if(m == 0 && l == 0 && r > 0){
cout << r << " " << p << endl;
}
if(m == 0 && l == 0 && r == 0){
cout << p;
}
e = m;
i++;
t = l;
n--;
}
}
Compilation message
Main.cpp: In function 'int main()':
Main.cpp:12:9: warning: 'e' may be used uninitialized in this function [-Wmaybe-uninitialized]
12 | if(m > e){
| ^~
Main.cpp:23:9: warning: 't' may be used uninitialized in this function [-Wmaybe-uninitialized]
23 | if(l > t){
| ^~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Correct |
1 ms |
204 KB |
Output is correct |
10 |
Correct |
1 ms |
204 KB |
Output is correct |
11 |
Correct |
1 ms |
204 KB |
Output is correct |
12 |
Correct |
1 ms |
264 KB |
Output is correct |
13 |
Correct |
1 ms |
204 KB |
Output is correct |
14 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
15 |
Halted |
0 ms |
0 KB |
- |