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;
const int N = 200010;
int v[N];
int main(){
int r, s;
cin >> r >> s;
int n = s;
int q;
for(int i = 0;i < n;i++){
cin >> v[i];
}
set <array <int, 3>> ranges;
for(int i = 0;i < n;i++){
int l = i, r = i;
while(v[l] == v[r] and r < n){
r++;
}
r--;
ranges.insert({l, r, v[i]});
i = r;
}
cin >> q;
for(int i = 0;i < q;i++){
int _, t, cor;
cin >> _ >> t >> cor;
t--;
auto it = ranges.lower_bound({t, n+10, 0});
it--;
int l = (*it)[0], r = (*it)[1];
ranges.erase(it);
it = ranges.lower_bound({t, n+10, 0});
if((*it)[2] == cor) {
r = (*it)[1];
ranges.erase(it);
}
it = ranges.lower_bound({t, n+10, 0});
if(it != ranges.end()){
it--;
if((*it)[2] == cor) {
l = (*it)[0];
ranges.erase(it);
}
}
ranges.insert({l, r, cor});
}
for(auto x : ranges){
for(int i = x[0];i <= x[1];i++){
cout << x[2] << ' ';
}
}
cout << 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... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |