제출 #1183320

#제출 시각아이디문제언어결과실행 시간메모리
1183320jerzykStone Arranging 2 (JOI23_ho_t1)C++20
100 / 100
152 ms43872 KiB
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> using namespace __gnu_pbds; using namespace std; #define pb push_back #define st first #define nd second typedef long long ll; typedef long double ld; const ll I = 1000'000'000'000'000'000LL; const int II = 2'000'000'000; const ll M = 1000'000'007LL; const int N = 1000'007; vector<int> pos[N]; vector<pair<int, int>> cur; map<int, int> nm; int rev[N]; void Solve() { int n, x, a; cin >> n; for(int i = 1; i <= n; ++i) { cin >> x; if(nm.find(x) == nm.end()) {nm[x] = i; rev[i] = x;} a = nm[x]; int d = 1; if(pos[a].size() > 0) { while(cur.back().st != a) { d += cur.back().nd; pos[cur.back().st].pop_back(); cur.pop_back(); } d += cur.back().nd; pos[a].pop_back(); cur.pop_back(); } pos[a].pb(i); cur.pb(make_pair(a, d)); } for(int i = 0; i < (int)cur.size(); ++i) for(int j = 0; j < (int)cur[i].nd; ++j) cout << rev[cur[i].st] << "\n"; } int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); //int t; 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...