Submission #769320

#TimeUsernameProblemLanguageResultExecution timeMemory
769320tch1cherinStone Arranging 2 (JOI23_ho_t1)C++17
100 / 100
197 ms15124 KiB
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<pair<int, int>> S; set<int> in_stack; for (int i = 0; i < n; i++) { int x; cin >> x; if (in_stack.count(x)) { while (S.back().first != x) { in_stack.erase(S.back().first); S.pop_back(); } } else { in_stack.insert(x); S.emplace_back(x, i); } } S.emplace_back(-1, n); for (int i = 0; i < (int)S.size() - 1; i++) { for (int j = S[i].second; j < S[i + 1].second; j++) { cout << S[i].first << "\n"; } } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...