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;
#pragma GCC optimize("O3,unroll-loops")
#define ll long long
#define pii pair<long long,long long>
#define F first
#define S second
#define pb emplace_back
#define endl "\n"
#define all(a) a.begin(),a.end()
#define int long long
void solve(){
int n;
cin>>n;
vector<pii> a;
set<int> vis;
for(int i=0;i<n;i++){
int x;
cin>>x;
if(vis.find(x)==vis.end()){
vis.insert(x);
a.pb(x,i);
}
else{
while(a.back().F!=x){
vis.erase(a.back().F);
a.pop_back();
}
}
}
int color,now=0;
vector<int> ans;
for(int i=0;i<n;i++){
if(now<(int)a.size()&&a[now].S==i) color=a[now].F,now++;
cout<<color<<endl;
}
}
signed main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
int t=1;
//cin>>t;
while(t--){
solve();
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |