1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include <assert.h>
#include <iostream>
#include <vector>
#include <chrono>
#include <algorithm>
#include <functional>
#include <iterator>

typedef unsigned char u8;

struct Op { int l, r, k; };

int main()
{
    int n;
    std::cin >> n;
    std::vector<u8> puszki(n);

    int m;
    std::cin >> m;

    for (int i = 0; i < m; i++) {
        Op x;
        std::cin >> x.l >> x.r >> x.k;
        u8 kolor = 1 << (x.k - 1);
        auto end = puszki.begin() + x.r;
        for (auto it = puszki.begin() + x.l - 1; it != end; ++it)
            *it |= kolor;
    }

    int count = std::count(puszki.begin(), puszki.end(), 3);

    std::cout << count << '\n';

    return 0;
}