Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <vector>
- #include "optimization.h"
- #include <tuple>
- using namespace std;
- vector<int> c, p;
- int n;
- int paint(int l, int r, int color) {
- if(l > r || l >= n || l < 0) {
- return l;
- }
- if(c[l] == -1) c[l] = color;
- return p[l] = paint(p[l], r, color);
- }
- int main() {
- n = readInt();
- int k = readInt();
- int m = readInt();
- vector<tuple<int, int, int>> q(m);
- for (int i = 0; i < m; ++i) {
- q[i] = {readInt() - 1, readInt() - 1, readInt() - 1};
- }
- c.resize(n, -1);
- p.resize(n, 0);
- for (int i = 0; i < n; ++i) {
- p[i] = i + 1;
- }
- for (auto i = m - 1; i >= 0; i--) {
- auto [cc, l, r] = q[i];
- paint(l, r, cc);
- }
- vector<int> count(k);
- for(int cc : c) {
- count[cc]++;
- }
- for (int cc : count) {
- writeInt(cc, ' ');
- }
- writeChar('\n');
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment