제출 #1156263

#제출 시각아이디문제언어결과실행 시간메모리
1156263Alihan_8Stone Arranging 2 (JOI23_ho_t1)C++20
100 / 100
193 ms15780 KiB
#include <bits/stdc++.h> using namespace std; signed main(){ int n; cin >> n; vector <int> a(n); for ( auto &u: a ) cin >> u; stack <array<int,3>> stk; stk.push({-1, 0, -1}); map <int,int> cnt; for ( int i = 0; i < n; i++ ){ if ( cnt[a[i]] ){ while ( stk.top()[0] != a[i] ){ auto [v, l, r] = stk.top(); stk.pop(); cnt[v] -= 1; } stk.top()[2] = i; } else{ stk.push({a[i], i, i}); cnt[a[i]] = 1; } } vector <int> val(n); while ( !stk.empty() ){ auto [v, l, r] = stk.top(); stk.pop(); for ( int i = l; i <= r; i++ ) val[i] = v; } for ( auto &x: val ) cout << x << '\n'; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...