Submission #1125219

#TimeUsernameProblemLanguageResultExecution timeMemory
1125219SulAStone Arranging 2 (JOI23_ho_t1)C++20
100 / 100
161 ms12620 KiB
#include <bits/stdc++.h> using namespace std; #include <ext/pb_ds/tree_policy.hpp> #include <ext/pb_ds/assoc_container.hpp> //#pragma GCC target("popcnt") using namespace __gnu_pbds; using namespace std; using ordered_set = tree<int, null_type, less_equal<>, rb_tree_tag, tree_order_statistics_node_update>; #define popcount __builtin_popcountll #define all(a) (a).begin(), (a).end() signed main() { ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); int n; cin >> n; int a[n]; for (int& x : a) cin >> x; map<int,int> last; for (int i = 0; i < n; i++) last[a[i]] = i; auto paint = [&](int l, int r, int c) { for (int i = l; i <= r; i++) a[i] = c; }; for (int i = 0; i < n; i = last[a[i]] + 1) { paint(i, last[a[i]], a[i]); } for (int x : a) cout << x << "\n"; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...