Submission #869578

# Submission time Handle Problem Language Result Execution time Memory
869578 2023-11-04T21:14:02 Z LucaLucaM Stone Arranging 2 (JOI23_ho_t1) C++17
60 / 100
2000 ms 8100 KB
#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) {
  return ((std::get<0>(a) <= std::get<0>(b)) && (std::get<1>(b) <= std::get<1>(a)));
}

int main() {
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(0);
  std::cout.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 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 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 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 0 ms 348 KB Output is correct
14 Correct 0 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 1 ms 348 KB Output is correct
18 Correct 1 ms 348 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 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 1 ms 344 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 1 ms 348 KB Output is correct
30 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 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 344 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 500 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 21 ms 5076 KB Output is correct
18 Correct 21 ms 4308 KB Output is correct
19 Correct 26 ms 5076 KB Output is correct
20 Correct 24 ms 4304 KB Output is correct
21 Correct 24 ms 4336 KB Output is correct
22 Correct 24 ms 5332 KB Output is correct
23 Correct 27 ms 5328 KB Output is correct
24 Correct 25 ms 4308 KB Output is correct
25 Correct 24 ms 4308 KB Output is correct
26 Correct 30 ms 5588 KB Output is correct
27 Correct 30 ms 4236 KB Output is correct
28 Correct 27 ms 4308 KB Output is correct
29 Correct 25 ms 2776 KB Output is correct
30 Correct 21 ms 4308 KB Output is correct
31 Correct 20 ms 4308 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 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 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 0 ms 348 KB Output is correct
14 Correct 0 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 1 ms 348 KB Output is correct
18 Correct 1 ms 348 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 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 1 ms 344 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 1 ms 348 KB Output is correct
30 Correct 1 ms 348 KB Output is correct
31 Correct 1 ms 348 KB Output is correct
32 Correct 0 ms 348 KB Output is correct
33 Correct 1 ms 348 KB Output is correct
34 Correct 0 ms 348 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 344 KB Output is correct
40 Correct 1 ms 348 KB Output is correct
41 Correct 1 ms 348 KB Output is correct
42 Correct 1 ms 500 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 21 ms 5076 KB Output is correct
48 Correct 21 ms 4308 KB Output is correct
49 Correct 26 ms 5076 KB Output is correct
50 Correct 24 ms 4304 KB Output is correct
51 Correct 24 ms 4336 KB Output is correct
52 Correct 24 ms 5332 KB Output is correct
53 Correct 27 ms 5328 KB Output is correct
54 Correct 25 ms 4308 KB Output is correct
55 Correct 24 ms 4308 KB Output is correct
56 Correct 30 ms 5588 KB Output is correct
57 Correct 30 ms 4236 KB Output is correct
58 Correct 27 ms 4308 KB Output is correct
59 Correct 25 ms 2776 KB Output is correct
60 Correct 21 ms 4308 KB Output is correct
61 Correct 20 ms 4308 KB Output is correct
62 Correct 29 ms 6088 KB Output is correct
63 Correct 100 ms 6996 KB Output is correct
64 Correct 103 ms 5980 KB Output is correct
65 Correct 33 ms 5080 KB Output is correct
66 Correct 32 ms 5840 KB Output is correct
67 Correct 33 ms 5064 KB Output is correct
68 Correct 36 ms 6096 KB Output is correct
69 Correct 35 ms 4880 KB Output is correct
70 Correct 37 ms 4648 KB Output is correct
71 Correct 49 ms 4680 KB Output is correct
72 Correct 35 ms 4808 KB Output is correct
73 Correct 102 ms 8100 KB Output is correct
74 Execution timed out 2025 ms 7384 KB Time limit exceeded
75 Halted 0 ms 0 KB -