제출 #936966

#제출 시각아이디문제언어결과실행 시간메모리
936966tianyaochiunStone Arranging 2 (JOI23_ho_t1)C++17
100 / 100
142 ms17140 KiB
#include<bits/stdc++.h> using namespace std; #pragma GCC optimize("O3,unroll-loops") #define ll long long #define pii pair<long long,long long> #define F first #define S second #define pb emplace_back #define endl "\n" #define all(a) a.begin(),a.end() #define int long long void solve(){ int n; cin>>n; vector<pii> a; set<int> vis; for(int i=0;i<n;i++){ int x; cin>>x; if(vis.find(x)==vis.end()){ vis.insert(x); a.pb(x,i); } else{ while(a.back().F!=x){ vis.erase(a.back().F); a.pop_back(); } } } int color,now=0; vector<int> ans; for(int i=0;i<n;i++){ if(now<(int)a.size()&&a[now].S==i) color=a[now].F,now++; cout<<color<<endl; } } signed main(){ ios_base::sync_with_stdio(0); cin.tie(0); int t=1; //cin>>t; while(t--){ solve(); } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...