Submission #953939

#TimeUsernameProblemLanguageResultExecution timeMemory
953939vjudge1Stone Arranging 2 (JOI23_ho_t1)C++98
100 / 100
364 ms16340 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...