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 pb push_back
#define pii pair<int,int>
#define ff first
#define ss second
const int maxn = 1e3+5;
int main(){
int n,m; cin >> n >> m;
vector<int> a(m+1);
for(int i=1; i<=m; i++) cin >> a[i];
set<int> st;
vector<int> cor(m+1);
for(int i=1; i<=m; i++) if(a[i]!=a[i-1]) st.insert(i), cor[i]=a[i];
int q; cin >> q;
while(q--){
int fds,id,c; cin >> fds >> id >> c;
auto ptr = prev(st.upper_bound(id));
cor[*ptr]=c;
if(ptr!=st.begin() && cor[*prev(ptr)]==c) st.erase(ptr);
auto ub = st.upper_bound(id);
if(ub!=st.end() && cor[*ub]==c) st.erase(ub);
}
vector<int> ans(m+1,0);
for(int x : st) ans[x]=cor[x];
for(int i=1; i<=m; i++){
if(!ans[i]) ans[i]=ans[i-1];
cout << ans[i] << " ";
}
cout << '\n';
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |