Submission #923238

#TimeUsernameProblemLanguageResultExecution timeMemory
923238ttamxStone Arranging 2 (JOI23_ho_t1)C++14
100 / 100
292 ms29028 KiB
#include<bits/stdc++.h> using namespace std; const int N=2e5+5; int n; int a[N],ans[N]; map<int,vector<int>> mp; stack<int> s; int main(){ cin.tie(nullptr)->sync_with_stdio(false); cin >> n; s.emplace(0); for(int i=1;i<=n;i++){ cin >> a[i]; auto &p=mp[a[i]]; if(!p.empty()){ while(s.top()>p.back()){ mp[a[s.top()]].pop_back(); s.pop(); } } s.emplace(i); p.emplace_back(i); } for(int i=n,col;i>=1;i--){ if(s.top()==i){ col=a[s.top()]; s.pop(); } ans[i]=col; } for(int i=1;i<=n;i++)cout << ans[i] << "\n"; }

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:33:15: warning: 'col' may be used uninitialized in this function [-Wmaybe-uninitialized]
   33 |         ans[i]=col;
      |         ~~~~~~^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...