Submission #774689

#TimeUsernameProblemLanguageResultExecution timeMemory
774689vjudge1Stone Arranging 2 (JOI23_ho_t1)C++17
100 / 100
383 ms21216 KiB
#include<bits/stdc++.h> using namespace std; #define int long long #define st first #define nd second const int maxn = 2e5 + 5; int n, a[maxn]; map<int, int> mp; signed main(){ cin.tie(0)->sync_with_stdio(0); cin >> n; for(int i = 1; i <= n ; i++) cin >> a[i]; for(int i = 1 ; i <= n ; i++){ mp[a[i]] = i; } int ptr = 1; vector<pair<int, pair<int, int>>> ans; while(ptr <= n){ // cout << a[ptr] << " " << ptr << " " << mp[a[ptr]] << endl; if(mp[a[ptr]] > ptr){ ans.push_back({a[ptr], {ptr, mp[a[ptr]]}}); } else ans.push_back({a[ptr], {ptr, ptr}}); ptr = mp[a[ptr]] + 1; } for(pair<int, pair<int, int>> v : ans){ for(int i = v.nd.st ; i <= v.nd.nd ; i++) cout << v.st << endl; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...