제출 #769520

#제출 시각아이디문제언어결과실행 시간메모리
769520OzyStone Arranging 2 (JOI23_ho_t1)C++17
100 / 100
176 ms20044 KiB
#include <iostream> #include <bits/stdc++.h> using namespace std; #define debug(a) cout << #a << " = " << a << endl #define debugsl(a) cout << #a << " = " << a << ", " #define lli long long int #define rep(i,a,b) for(int i = (a); i <= (b); i++) #define repa(i,a,b) for(int i = (a); i >= (b); i--) #define pll pair<lli,lli> //para la deque #define ai first #define id second lli n,a; map<lli,lli> existe; deque<pll> pila; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cin >> n; rep(i,1,n) { cin >> a; if (existe.find(a) == existe.end() || existe[a] == 0) { pila.push_back({a,i}); existe[a] = 1; continue; } while (pila.back().ai != a) { existe[pila.back().ai] = 0; pila.pop_back(); } pila.pop_back(); pila.push_back({a,i}); } rep(i,1,n) { cout << pila.front().ai << "\n"; if (i == pila.front().id) pila.pop_front(); } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...