답안 #1003989

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1003989 2024-06-20T21:15:04 Z vjudge1 Paint (COI20_paint) C++17
9 / 100
117 ms 11056 KB
#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 << " ";
		}
	}



}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 85 ms 4376 KB Output is correct
2 Correct 98 ms 6228 KB Output is correct
3 Correct 117 ms 11056 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -