Submission #1231341

#TimeUsernameProblemLanguageResultExecution timeMemory
1231341k1r1t0Stone Arranging 2 (JOI23_ho_t1)C++20
100 / 100
151 ms18104 KiB
#include <bits/stdc++.h> using namespace std; #define int long long const int N = 210000; int n, a[N]; map<int, bool> mp; int32_t main() { ios::sync_with_stdio(0); cin.tie(0); cin >> n; for (int i = 1; i <= n; i++) cin >> a[i]; stack<int> st; for (int i = 1; i <= n; i++) { if (mp[a[i]]) { while (a[st.top()] != a[i]) { mp[a[st.top()]] = false; st.pop(); } } else { mp[a[i]] = true; st.push(i); } } for (int i = n; i >= 1; i--) { while (st.top() > i) st.pop(); a[i] = a[st.top()]; } for (int i = 1; i <= n; i++) cout << a[i] << '\n'; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...