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>
typedef long long ll;
#define FOR(i,x,y) for(ll i=x; i<y; i++)
#define FORNEG(i,x,y) for(ll i=x; i>y; i--)
using namespace std;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
ll n;
cin >> n;
vector<ll> vals(n);
map<ll,ll> last;
FOR(i,0,n){
ll temp;
cin >> temp;
vals[i] = (temp);
last[temp] = i;
}
ll cur = -1;
FOR(i,0,n){
if (cur==-1) cur = vals[i];
if (vals[i] == cur && last[vals[i]] == i) cur = -1;
else vals[i] = cur;
}
for (auto&i : vals) cout << i << endl;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |