제출 #1316506

#제출 시각아이디문제언어결과실행 시간메모리
1316506ghos007Stone Arranging 2 (JOI23_ho_t1)C++20
100 / 100
180 ms28932 KiB
//#define _GLIBCXX_DEBUG #include <bits/stdc++.h> #define int long long using namespace std; struct node { int color; pair<int,int> sect; node() = default; node(int val,int l,int r) : color(val), sect(l,r) {} }; signed main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n; cin >> n; vector <int> vec(n); for (int i = 0; i < n; i++) { cin >> vec[i]; } vector <int> all_sect; map <int,vector <pair<int,int>>> mp; for (int i = 0;i < n;i++) { if (mp[vec[i]].size() == 0) { all_sect.push_back(vec[i]); mp[vec[i]].push_back(pair<int,int>(i,i)); }else { while (all_sect.back() != vec[i]) { mp[all_sect.back()].pop_back(); all_sect.pop_back(); } mp[all_sect.back()].back().second = i; } } vector <int> ans(n); for (auto el : mp) { for (auto i :el.second) { for (int j = i.first;j <= i.second;j++) { ans[j] = el.first; } } } for (auto el : ans) { cout << el << "\n"; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...