Submission #997899

#TimeUsernameProblemLanguageResultExecution timeMemory
997899yanbStone Arranging 2 (JOI23_ho_t1)C++14
100 / 100
109 ms18004 KiB
#include <bits/stdc++.h> using namespace std; #define int long long signed main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); int n; cin >> n; vector<int> a(n); for (int i = 0; i < n; i++) cin >> a[i]; vector<int> nxt(n); map<int, int> last; for (int i = n - 1; i >= 0; i--) { nxt[i] = (last[a[i]] ? last[a[i]] : -1); last[a[i]] = i; } int i = 0; while (i < n) { int x = i; for (; i < nxt[x]; i++) { a[i] = a[x]; } if (x == i) i++; } for (int i = 0; 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...