Submission #1131544

#TimeUsernameProblemLanguageResultExecution timeMemory
1131544lopkusStone Arranging 2 (JOI23_ho_t1)C++20
100 / 100
134 ms17992 KiB
#include <bits/stdc++.h> #define int long long using namespace std; signed main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n; cin >> n; vector<int> a(n + 1); for(int i = 1; i <= n; i++) { cin >> a[i]; } vector<int> ans(n + 1); map<int,int> M; for(int i = 1; i <= n; i++) { M[a[i]] = i; } int currentr = 0; for(int i = 1; i <= n; i++) { if(i == currentr + 1) { currentr = M[a[i]]; } ans[i] = a[currentr]; } for(int i = 1; i <= n; i++) { cout << ans[i] << " "; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...