# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
787908 | guagua0407 | Stone Arranging 2 (JOI23_ho_t1) | C++17 | 163 ms | 15156 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |