# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1034597 | juicy | Stone Arranging 2 (JOI23_ho_t1) | C++17 | 144 ms | 15336 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 42
#endif
int main() {
ios::sync_with_stdio(false); cin.tie(nullptr);
int N; cin >> N;
vector<int> A(N);
map<int, int> cnt;
vector<int> st;
for (int i = 0; i < N; ++i) {
cin >> A[i];
if (cnt[A[i]] > 0) {
while (st.size() && A[st.back()] != A[i]) {
--cnt[A[st.back()]];
st.pop_back();
}
}
++cnt[A[i]];
st.push_back(i);
}
for (int i = 0; i < st.size(); ++i) {
int l = st[i], r = i + 1 == st.size() ? N - 1 : st[i + 1] - 1;
int cnt = r - l + 1;
while (cnt--) {
cout << A[l] << "\n";
}
}
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |