Submission #955443

#TimeUsernameProblemLanguageResultExecution timeMemory
955443BaytoroStone Arranging 2 (JOI23_ho_t1)C++17
100 / 100
235 ms16068 KiB
#include <bits/stdc++.h> using namespace std; #define ios ios::sync_with_stdio(false); cin.tie(NULL); #define pb push_back #define all(x) x.begin(), x.end() #define rall(x) x.rbegin(), x.rend() #define fr first #define sc second #define mp make_pair #define ll long long //#define int ll #define double long double const ll INF=1e18,N=1e6+5; void solve(){ int n;cin>>n; map<int,int> mpp; vector<int> ans(n); vector<pair<int,int> > st; for(int i=0;i<n;i++){ int x;cin>>x; if(mpp[x]>0){ while(!st.empty()){ if(st.back().fr==x) break; mpp[st.back().fr]--; st.pop_back(); } } st.pb(mp(x,i)); mpp[x]++; } st.pb(mp(-1,n)); for(int i=0;i<st.size()-1;i++){ int k=st[i].sc; while(k<st[i+1].sc){ ans[k]=st[i].fr; k++; } } for(int i=0;i<n;i++) cout<<ans[i]<<'\n'; } int main(){ solve(); }

Compilation message (stderr)

Main.cpp: In function 'void solve()':
Main.cpp:33:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |  for(int i=0;i<st.size()-1;i++){
      |              ~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...