Submission #774723

#TimeUsernameProblemLanguageResultExecution timeMemory
774723vjudge1Stone Arranging 2 (JOI23_ho_t1)C++17
100 / 100
324 ms30488 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define endl '\n' #define dbg(x) cout << (#x) << " = " << x << endl const ll maxn = 2e5 + 69; ll a[maxn],b[maxn],n; map<ll,ll> cnt,pre; int main(){ ios_base::sync_with_stdio(false); cin.tie(0); cin >> n; for(int i = 1;i<=n;i++){ cin >> a[i]; b[i] = a[i]; if(cnt[a[i]] == 0) cnt[a[i]] = i; if(cnt[a[i]]) pre[a[i]] = i; } ll pt = 1; while(pt <= n){ if(pre[a[pt]]){ ll temp = pt; while(pt != pre[a[temp]]){ b[pt] = a[temp]; pt++; } b[pt] = a[temp]; pt++; }else pt++; } for(int i = 1;i<=n;i++) cout << b[i] << endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...