Submission #846994

#TimeUsernameProblemLanguageResultExecution timeMemory
846994StefanSebezStone Arranging 2 (JOI23_ho_t1)C++14
100 / 100
155 ms15304 KiB
#include <bits/stdc++.h> using namespace std; map<int,int>mapa; int main() { int n; scanf("%i",&n); int a[n+1]; for(int i=1;i<=n;i++) { scanf("%i",&a[i]); } vector<int>b; for(int i=1;i<=n;i++) { if(mapa[a[i]]>0) { while(a[b.back()]!=a[i]) { mapa[a[b.back()]]--; b.pop_back(); } } mapa[a[i]]++; b.push_back(i); } /*for(auto i:b)cout<<i<<" "; cout<<endl;*/ for(int i=0;i<b.size();i++) { printf("%i ",a[b[i]]); if(i==b.size()-1) break; for(int j=b[i]+1;j<b[i+1];j++) { printf("%i ",a[b[i]]); } } return 0; }

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:29:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |  for(int i=0;i<b.size();i++)
      |              ~^~~~~~~~~
Main.cpp:32:7: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |   if(i==b.size()-1) break;
      |      ~^~~~~~~~~~~~
Main.cpp:7:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    7 |     scanf("%i",&n);
      |     ~~~~~^~~~~~~~~
Main.cpp:11:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |   scanf("%i",&a[i]);
      |   ~~~~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...