# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1121211 | Neco_arc | Stone Arranging 2 (JOI23_ho_t1) | C++17 | 83 ms | 15388 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>
#define ll long long
#define name "Stone Arranging 2"
#define fi(i, a, b) for(int i = a; i <= b; ++i)
#define fid(i, a, b) for(int i = a; i <= b; --i)
#define maxn (int) (2e5 + 7)
using namespace std;
int n;
unordered_map<int, int> d;
vector<pair<int, int>> P;
void solve() {
cin >> n;
fi(i, 1, n) {
int x; cin >> x;
if(!d[x]) P.push_back({i, x}), d[x] = 1;
else {
while(P.back().second != x) d[P.back().second] = 0, P.pop_back();
P.back().first = i;
}
}
reverse(P.begin(), P.end());
fi(i, 1, n) {
while(i > P.back().first) P.pop_back();
cout << P.back().second << '\n';
}
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0), cout.tie(0);
if(fopen(name".inp", "r")) {
freopen(name".inp", "r", stdin);
freopen(name".out", "w", stdout);
}
solve();
}
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... |