Submission #1003989

#TimeUsernameProblemLanguageResultExecution timeMemory
1003989vjudge1Paint (COI20_paint)C++17
9 / 100
117 ms11056 KiB
#include<bits/stdc++.h> using namespace std; #define int long long #define pb push_back #define mp make_pair #define fr first #define sc second #define all(x) x.begin(),x.end() const int maxn = -1; const int inf = 1e18+10; int32_t main() { // #ifndef ONLINE_JUDGE // freopen("in.in","r",stdin); // freopen("out.out","w",stdout); // #endif int n,m; cin >> n >> m; vector<int> a(m+10); set<pair<pair<int,int>,int>> lrs; for(int i = 1; i <= m; i++) { cin >> a[i]; if(lrs.size() && prev(lrs.end())->sc == a[i]) { int l = prev(lrs.end())->fr.fr; lrs.erase(prev(lrs.end())); lrs.insert(mp(mp(l,i),a[i])); } else { lrs.insert(mp(mp(i,i),a[i])); } } int q; cin >> q; while(q--) { int i,j,c; cin >> i >> j >> c; auto it = prev(lrs.upper_bound(mp(mp(j,inf),inf))); int l = it->fr.fr; int r = it->fr.sc; // cout << l << " " << r << " " << it->sc << endl; vector<pair<pair<int,int>,int>> rem; rem.pb(mp(mp(l,r),it->sc)); if(it != lrs.begin() && prev(it)->sc == c) { l = prev(it)->fr.fr; rem.pb(mp(mp(prev(it)->fr.fr,prev(it)->fr.sc),prev(it)->sc)); } if(next(it) != lrs.end() && next(it)->sc == c) { r = next(it)->fr.sc; rem.pb(mp(mp(next(it)->fr.fr,next(it)->fr.sc),next(it)->sc)); } for(auto x : rem) lrs.erase(x); lrs.insert(mp(mp(l,r),c)); // cout << l << " " << r << " " << c << endl; } for(auto x : lrs) { int l = x.fr.fr; int r = x.fr.sc; int c = x.sc; for(int i = l; i <= r; i++) { cout << c << " "; } } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...