Submission #1036718

#TimeUsernameProblemLanguageResultExecution timeMemory
1036718andrewpStone Arranging 2 (JOI23_ho_t1)C++14
100 / 100
133 ms15188 KiB
//Dedicated to my love, ivaziva #include <bits/stdc++.h> using namespace std; using pii = pair<int, int>; using ll = int64_t; #define all(x) x.begin(), x.end() #define rall(x) x.rbegin(), x.rend() #define dbg(x) cerr << #x << ": " << x << '\n'; int32_t main() { ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); cerr.tie(nullptr); int n; cin >> n; vector<int> a(n); map<int, int> pos; for (int i = 0; i < n; i++) { cin >> a[i]; pos[a[i]] = i; } vector<int> ans(n); int ptr = -1; for (int i = 0; i < n; i++) { if (i == ptr + 1) { ptr = pos[a[i]]; } ans[i] = a[ptr]; } for (int x: ans) cout << x << '\n'; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...