이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |