Submission #926913

#TimeUsernameProblemLanguageResultExecution timeMemory
926913goodspeed0208Stone Arranging 2 (JOI23_ho_t1)C++14
100 / 100
208 ms20052 KiB
#include<bits/stdc++.h> #define int long long #define pii pair<long long, long> #define INF 10000000000000000 using namespace std; signed main() { int n; cin >> n; vector<int>v(n); vector<int>next(n, -1); map<int, int>mp; for (int i = 0 ; i < n ; i++) { cin >> v[i]; if (mp.find(v[i]) != mp.end()) { next[mp[v[i]]] = i; } mp[v[i]] = i; } //for (int i = 0 ; i < n ; i++) cout << next[i] << " "; //cout << "\n"; for (int i = 0 ; i < n ; i++) { if (next[i] == -1) continue; int j; for (j = i+1 ; j <= next[i] ; j++) { v[j] = v[i]; } i = next[i]-1; } for (int i = 0 ; i < n ; i++) cout << v[i] << "\n"; //cout << "\n"; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...