#include <iostream>
#include <vector>
#include <algorithm>
#include <cassert>
#include <cstring>
#include <functional>
#include <set>
#include <stack>
#warning That's the baby, that's not my baby
typedef long long ll;
bool inside (std::tuple<int, int, int> a, std::tuple<int, int, int> b) {
int x1 = std::get<0>(a), y1 = std::get<1>(a);
int x2 = std::get<0>(b), y2 = std::get<1>(b);
return (x1 <= x2 && y2 <= y1);
}
int main() {
std::ios_base::sync_with_stdio(false);
std::cin.tie(0);
int n;
std::cin >> n;
int a[n];
std::stack<int> st;
std::set<int> inStack;
std::vector<std::tuple<int, int, int>> updates;
for (int i = 0; i < n; i++) {
std::cin >> a[i];
if (inStack.count(a[i])) {
while (a[st.top()] != a[i]) {
inStack.erase(a[st.top()]);
st.pop();
}
std::tuple<int, int, int> cur = {st.top(), i, a[i]};
if (!updates.empty() && inside(updates.back(), cur)) {
updates.pop_back();
}
updates.push_back(cur);
st.pop();
st.push(i);
} else {
inStack.insert(a[i]);
st.push(i);
}
}
for (const auto &[l, r, v] : updates) {
for (int i = l; i <= r; i++) {
a[i] = v;
}
}
for (int i = 0; i < n; i++) {
std::cout << a[i] << '\n';
}
return 0;
}
Compilation message
Main.cpp:9:2: warning: #warning That's the baby, that's not my baby [-Wcpp]
9 | #warning That's the baby, that's not my baby
| ^~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 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 |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
516 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
420 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
1 ms |
348 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
1 ms |
600 KB |
Output is correct |
19 |
Correct |
1 ms |
348 KB |
Output is correct |
20 |
Correct |
1 ms |
348 KB |
Output is correct |
21 |
Correct |
1 ms |
544 KB |
Output is correct |
22 |
Correct |
1 ms |
348 KB |
Output is correct |
23 |
Correct |
2 ms |
348 KB |
Output is correct |
24 |
Correct |
1 ms |
516 KB |
Output is correct |
25 |
Correct |
1 ms |
472 KB |
Output is correct |
26 |
Correct |
1 ms |
348 KB |
Output is correct |
27 |
Correct |
1 ms |
348 KB |
Output is correct |
28 |
Correct |
1 ms |
348 KB |
Output is correct |
29 |
Correct |
1 ms |
468 KB |
Output is correct |
30 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 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 |
344 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
456 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
1 ms |
348 KB |
Output is correct |
17 |
Correct |
22 ms |
4820 KB |
Output is correct |
18 |
Correct |
21 ms |
4820 KB |
Output is correct |
19 |
Correct |
30 ms |
5076 KB |
Output is correct |
20 |
Correct |
24 ms |
4820 KB |
Output is correct |
21 |
Correct |
24 ms |
4820 KB |
Output is correct |
22 |
Correct |
25 ms |
4684 KB |
Output is correct |
23 |
Correct |
25 ms |
5844 KB |
Output is correct |
24 |
Correct |
25 ms |
4820 KB |
Output is correct |
25 |
Correct |
30 ms |
5588 KB |
Output is correct |
26 |
Correct |
30 ms |
5588 KB |
Output is correct |
27 |
Correct |
24 ms |
4816 KB |
Output is correct |
28 |
Correct |
25 ms |
5384 KB |
Output is correct |
29 |
Correct |
30 ms |
3288 KB |
Output is correct |
30 |
Correct |
28 ms |
5588 KB |
Output is correct |
31 |
Correct |
21 ms |
4820 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 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 |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
516 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
420 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
1 ms |
348 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
1 ms |
600 KB |
Output is correct |
19 |
Correct |
1 ms |
348 KB |
Output is correct |
20 |
Correct |
1 ms |
348 KB |
Output is correct |
21 |
Correct |
1 ms |
544 KB |
Output is correct |
22 |
Correct |
1 ms |
348 KB |
Output is correct |
23 |
Correct |
2 ms |
348 KB |
Output is correct |
24 |
Correct |
1 ms |
516 KB |
Output is correct |
25 |
Correct |
1 ms |
472 KB |
Output is correct |
26 |
Correct |
1 ms |
348 KB |
Output is correct |
27 |
Correct |
1 ms |
348 KB |
Output is correct |
28 |
Correct |
1 ms |
348 KB |
Output is correct |
29 |
Correct |
1 ms |
468 KB |
Output is correct |
30 |
Correct |
1 ms |
348 KB |
Output is correct |
31 |
Correct |
0 ms |
348 KB |
Output is correct |
32 |
Correct |
0 ms |
348 KB |
Output is correct |
33 |
Correct |
0 ms |
348 KB |
Output is correct |
34 |
Correct |
0 ms |
344 KB |
Output is correct |
35 |
Correct |
1 ms |
348 KB |
Output is correct |
36 |
Correct |
1 ms |
348 KB |
Output is correct |
37 |
Correct |
0 ms |
348 KB |
Output is correct |
38 |
Correct |
0 ms |
348 KB |
Output is correct |
39 |
Correct |
1 ms |
348 KB |
Output is correct |
40 |
Correct |
1 ms |
456 KB |
Output is correct |
41 |
Correct |
1 ms |
348 KB |
Output is correct |
42 |
Correct |
1 ms |
348 KB |
Output is correct |
43 |
Correct |
1 ms |
348 KB |
Output is correct |
44 |
Correct |
1 ms |
348 KB |
Output is correct |
45 |
Correct |
1 ms |
348 KB |
Output is correct |
46 |
Correct |
1 ms |
348 KB |
Output is correct |
47 |
Correct |
22 ms |
4820 KB |
Output is correct |
48 |
Correct |
21 ms |
4820 KB |
Output is correct |
49 |
Correct |
30 ms |
5076 KB |
Output is correct |
50 |
Correct |
24 ms |
4820 KB |
Output is correct |
51 |
Correct |
24 ms |
4820 KB |
Output is correct |
52 |
Correct |
25 ms |
4684 KB |
Output is correct |
53 |
Correct |
25 ms |
5844 KB |
Output is correct |
54 |
Correct |
25 ms |
4820 KB |
Output is correct |
55 |
Correct |
30 ms |
5588 KB |
Output is correct |
56 |
Correct |
30 ms |
5588 KB |
Output is correct |
57 |
Correct |
24 ms |
4816 KB |
Output is correct |
58 |
Correct |
25 ms |
5384 KB |
Output is correct |
59 |
Correct |
30 ms |
3288 KB |
Output is correct |
60 |
Correct |
28 ms |
5588 KB |
Output is correct |
61 |
Correct |
21 ms |
4820 KB |
Output is correct |
62 |
Correct |
31 ms |
7624 KB |
Output is correct |
63 |
Correct |
100 ms |
9012 KB |
Output is correct |
64 |
Correct |
100 ms |
8020 KB |
Output is correct |
65 |
Correct |
34 ms |
6780 KB |
Output is correct |
66 |
Correct |
34 ms |
6600 KB |
Output is correct |
67 |
Correct |
44 ms |
6856 KB |
Output is correct |
68 |
Correct |
35 ms |
6852 KB |
Output is correct |
69 |
Correct |
39 ms |
7060 KB |
Output is correct |
70 |
Correct |
37 ms |
6764 KB |
Output is correct |
71 |
Correct |
39 ms |
6868 KB |
Output is correct |
72 |
Correct |
38 ms |
6572 KB |
Output is correct |
73 |
Correct |
100 ms |
10024 KB |
Output is correct |
74 |
Execution timed out |
2102 ms |
9300 KB |
Time limit exceeded |
75 |
Halted |
0 ms |
0 KB |
- |