Submission #787908

#TimeUsernameProblemLanguageResultExecution timeMemory
787908guagua0407Stone Arranging 2 (JOI23_ho_t1)C++17
100 / 100
163 ms15156 KiB
#include<bits/stdc++.h> using namespace std; #define ll long long #define f first #define s second #define all(x) x.begin(),x.end() vector<pair<int,int>> vec; map<int,int> mp; int main(){ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin>>n; for(int i=0;i<n;i++){ int x; cin>>x; if(mp[x]){ while(vec.size() and vec.back().f!=x){ mp[vec.back().f]--; vec.pop_back(); } } vec.push_back({x,i}); mp[x]++; } for(int i=0;i<vec.size()-1;i++){ if(vec[i].f==vec[i+1].f){ for(int j=vec[i].s;j<vec[i+1].s;j++){ cout<<vec[i].f<<'\n'; } } else{ cout<<vec[i].f<<'\n'; } } cout<<vec.back().f; }

Compilation message (stderr)

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