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;
const int MAX_N = 200000;
int N;
deque<pair<int, pair<int, int>>> dqa;
set<int> seta;
int main(){
cin.tie(0);
cout.tie(0);
ios::sync_with_stdio(false);
cin >> N;
for(int i = 0; i < N; i++){
int A;
cin >> A;
if(seta.count(A) == 0){
dqa.push_back(make_pair(A, make_pair(i, i)));
seta.insert(A);
}else{
for(;;){
pair<int, pair<int, int>> back = dqa.back();
dqa.pop_back();
if(back.first == A){
dqa.push_back(make_pair(A, make_pair(back.second.first, i)));
break;
}
seta.erase(back.first);
}
}
}
for(;;){
if(dqa.empty()) break;
pair<int, pair<int, int>> front = dqa.front();
dqa.pop_front();
for(int i = front.second.first; i <= front.second.second; i++) cout << front.first << endl;
}
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... |