# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
924652 | biank | Stone Arranging 2 (JOI23_ho_t1) | C++14 | 0 ms | 0 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;#define forn(i,n) for(int i=0;i<int(n);i++)#define forsn(i,s,n) for(int i=int(s);i<int(n);i++)int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin >> n; vector<int> a(n); map<int,int> last; forn(i,n){ cin >> a[i]; last[a[i]]=i; }
forn(i,n){
int j=last[a[i]];
forsn(k,i,j) a[k]=a[j];
i=j;
}
forn(i,n) cout << a[i] << '\n';
}