Submission #1125604

#TimeUsernameProblemLanguageResultExecution timeMemory
1125604salmonStone Arranging 2 (JOI23_ho_t1)C++20
100 / 100
188 ms14164 KiB
#include <bits/stdc++.h> using namespace std; int N; vector<int> steck; int h; int lst[200100]; set<int> sat; int main(){ scanf(" %d",&N); for(int i = 0; i < N; i++){ scanf(" %d",&h); lst[i] = h; if(sat.find(h) != sat.end()){ while(!steck.empty() && lst[steck.back()] != h ){ sat.erase(lst[steck.back()]); steck.pop_back(); } steck.pop_back(); } sat.insert(h); steck.push_back(i); } vector<int> ans; int c = lst[steck.back()]; for(int i = N - 1; i >= 0; i--){ if(!steck.empty() && i <= steck.back()){ c = lst[steck.back()]; steck.pop_back(); } ans.push_back(c); } reverse(ans.begin(),ans.end()); for(int i : ans){ printf("%d\n",i); } }

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:12:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |     scanf(" %d",&N);
      |     ~~~~~^~~~~~~~~~
Main.cpp:15:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |         scanf(" %d",&h);
      |         ~~~~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...