Submission #893401

#TimeUsernameProblemLanguageResultExecution timeMemory
893401granadierfcStone Arranging 2 (JOI23_ho_t1)C++14
100 / 100
424 ms15980 KiB
#include<bits/stdc++.h> using namespace std; void AC() { int n; cin >> n; vector<int> A(n); for(int i=0;i<n;i++){cin >> A[i] ;} map<int,bool> vis; vector<pair<int,int>> que; for(int i = 0; i < n; i++) { if(!vis[A[i]]){vis[A[i]]=true; que.push_back({1,A[i]}) ;} else{ int cnt=1; while(que.back().second != A[i]){cnt+=que.back().first; vis[que.back().second]=false; que.pop_back();} que.push_back({cnt, A[i]}) ;} } for(auto pr: que){ for(int i = 0; i < pr.first; i++) {cout << pr.second << endl;} } } int main() { //freopen("ip.txt", "r", stdin); //freopen("op.txt", "w", stdout); int t = 1; // cin >> t; while(t--) { AC(); } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...