Submission #938552

#TimeUsernameProblemLanguageResultExecution timeMemory
938552the_coding_poohStone Arranging 2 (JOI23_ho_t1)C++14
100 / 100
134 ms16152 KiB
#include <bits/stdc++.h> #define uwu return 0; using namespace std; const int SIZE = 2e5 + 5; int arr[SIZE]; int N; deque<pair<int, int>> stk; set<int> color; #define fs first #define sc second int main(){ cin.tie(0), ios::sync_with_stdio(0); cin >> N; for (int i = 0; i < N;i++){ cin >> arr[i]; } for (int i = 0; i < N;i++){ if(color.count(arr[i])){ while(stk.back().sc != arr[i]){ color.erase(stk.back().sc); stk.pop_back(); } } else{ color.insert(arr[i]); stk.push_back({i, arr[i]}); } } for (int i = N - 1; i >= 0;i--){ while(i < stk.back().fs){ stk.pop_back(); } arr[i] = stk.back().sc; } for (int i = 0; i < N;i++){ cout << arr[i] << '\n'; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...