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;
void solve(){
int n,sz = 0;
cin >> n;
map < int , int > last;
vector < array < int , 3 > > v;
//cout << n << " flag" << endl;
while(n--){
int x;cin >> x;
//cout << "query : " << x << endl;
if(last.count(x)){
//cout << "case : " << last[x] << endl;
sz++;
while((last[x]-1) != (int)v.size()){
v.pop_back();
}
v.push_back({x,v.back()[2]+1,sz});
}
else{
//cout << "case2" << endl;
sz++;
v.push_back({x,sz,sz});
}
last[x] = v.size();
//cout << "v : ";for(auto itr : v)cout << itr[0] << "," << itr[1] << "," << itr[2] << " ";cout << endl;
}
for(auto itr : v){
for(int j = 0;j<(itr[2] - itr[1] + 1);j++){
cout << itr[0] << '\n';
}
}
cout << endl;
}
signed main(){
ios_base::sync_with_stdio(0);cin.tie(0);
int testcase = 1;//cin >> testcase;
while(testcase--)solve();
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |