Submission #1003891

#TimeUsernameProblemLanguageResultExecution timeMemory
1003891vjudge1Paint (COI20_paint)C++17
9 / 100
105 ms10132 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...