제출 #1039796

#제출 시각아이디문제언어결과실행 시간메모리
1039796ymmStone Arranging 2 (JOI23_ho_t1)C++17
100 / 100
149 ms17684 KiB
#include <bits/stdc++.h> #define Loop(x,l,r) for (ll x = (l); x < (ll)(r); ++x) #define LoopR(x,l,r) for (ll x = (r)-1; x >= (ll)(l); --x) typedef long long ll; typedef std::pair<int, int> pii; typedef std::pair<ll , ll > pll; using namespace std; int main() { cin.tie(0) -> sync_with_stdio(false); int n; cin >> n; map<int, pii> seg; vector<int> vseg; Loop (i,0,n) { int x; cin >> x; auto it = seg.find(x); if (it == seg.end()) { seg[x] = {i, i + 1}; vseg.push_back(x); } else { seg[x].second = i + 1; while (vseg.back() != x) { seg.erase(vseg.back()); vseg.pop_back(); } } } for (auto x : vseg) { auto [l, r] = seg[x]; // cerr << x << ' ' << l << ' ' << r << '\n'; Loop (_,0,r-l) cout << x << '\n'; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...