이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
void solve(){
int n,sz = 0;
cin >> n;
map < int , int > last;
stack < array < int , 3 > > v;
while(n--){
int x;cin >> x;
if(last.count(x)){
sz++;
while(v.size() and (last[x]-1) != (int)v.size()){
v.pop();
}
v.push({x,(v.size() ? v.top()[2] : 0)+1,sz});
}
else{
sz++;
v.push({x,sz,sz});
}
last[x] = v.size();
}
vector < array < int , 3 > > vv;
while(v.size()){
vv.push_back(v.top());
v.pop();
}
reverse(vv.begin() , vv.end());
for(auto itr : vv){
for(int j = 0;j<(itr[2] - itr[1] + 1);j++){
cout << itr[0] << '\n';
}
}
}
signed main(){
ios_base::sync_with_stdio(0);cin.tie(0);cout.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... |