제출 #1333258

#제출 시각아이디문제언어결과실행 시간메모리
1333258wstcubeStone Arranging 2 (JOI23_ho_t1)C++20
0 / 100
1 ms344 KiB
#include <bits/stdc++.h>
#define fi first
#define se second
#define ll long long
#define pb push_back
using namespace std;
const int N = 2e5+5;

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    set<int> cur;
    int w;
    vector<pair<int,int>> st;
    for(int i =1;i<=n;i++){
        cin >> a[i];
        if(!cur.count(a[i])){
            cur.insert(a[i]);
            st.pb({a[i],i});
        }
        else{
            while(st.back().fi != a[i]){
                cur.erase(st.back().fi);
                st.pop_back();
            }
        }

    }
    st.pb({-1,n+1});
    for(int i=0;i<st.size()-1;i++){
        for(int j=st[i].se;j<st[i+1].se;j++){
            cout << st[i].fi << ' ';
        }
    }
    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...