Submission #835051

#TimeUsernameProblemLanguageResultExecution timeMemory
835051jasminStone Arranging 2 (JOI23_ho_t1)C++17
100 / 100
154 ms21456 KiB
//JOI 2023 Final Round #include<bits/stdc++.h> using namespace std; #define int long long signed main(){ ios_base::sync_with_stdio(false); cin.tie(0); int n; cin >> n; vector<int> a(n); for(int i=0; i<n; i++){ cin >> a[i]; } vector<int> stack; stack.push_back(-1); map<int,int> cnt; for(int i=0; i<n; i++){ cnt[a[i]]++; if(cnt[a[i]]==1){ stack.push_back(i); continue; } while(!stack.empty() && a[stack.back()]!=a[i]){ cnt[a[stack.back()]]--; stack.pop_back(); } stack.push_back(i); } vector<int> col(n); int s=stack.size(); for(int i=s-1; i>0; i--){ for(int j=stack[i]; j>stack[i-1]; j--){ col[j] = a[stack[i]]; } } for(auto e: col){ cout << e << "\n"; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...