Submission #769315

#TimeUsernameProblemLanguageResultExecution timeMemory
769315tch1cherinStone Arranging 2 (JOI23_ho_t1)C++17
35 / 100
40 ms1076 KiB
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<pair<int, int>> S; vector<bool> in_stack(n); for (int i = 0; i < n; i++) { int x; cin >> x; if (in_stack[--x]) { while (!S.empty() && S.back().first != x) { in_stack[S.back().first] = false; S.pop_back(); } } else { in_stack[x] = true; 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 << 1 + S[i].first << "\n"; } } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...