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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#include <bits/stdc++.h>

using namespace std;

struct Element {
    bool has_red;
    bool has_yellow;
    bool has_blue;
};

int main(void) {
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);

    int n, m, l, r, k;
    int count = 0;
    cin>>n>>m;

    Element def;
    def.has_blue = false;
    def.has_red = false;
    def.has_yellow = false;

    Element array[n];
    fill(array, array+n, def);

    for (int i=0; i<m; ++i) {
        cin>>l>>r>>k;

        for (int j=l-1; j<r; ++j) {
            
            switch (k) {
                case 1:
                    array[j].has_yellow = true;
                    break;
                
                case 2:
                    array[j].has_blue = true;
                    break;
                
                case 3:
                    array[j].has_red = true;
                    break;
            }
        }
    }

    for (int i=0; i<n; ++i) {
        if (array[i].has_blue == true && array[i].has_yellow == true && array[i].has_red == false) {
            ++count;
        }
    }

    cout<<count;
    return 0;
}