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
#include <iostream>

using namespace std;

int main()
{
    int n,m;
    cin >> n >> m;
    string * tab = new string[n];
    for(int i=0; i<n; ++i){
        tab[i] = "";
    }

    for(int i=0; i<m; ++i){
        int l,r,k;
        cin >> l >> r >> k;
        for(int j=l; j<=r; ++j){
            string color;
            if(k==1) color = "z";
            else if(k==2) color = "n";
            else if(k==3) color = "c";
            tab[j-1]+=color;
        }
    }

    int counter = 0;
    for(int i=0; i<n; ++i){
        int z_counter = 0;
        int n_counter = 0;
        int c_counter = 0;
        string temp = tab[i];
        for(int j=0; j<temp.size(); ++j){
            if(temp[j]=='z') z_counter++;
            else if(temp[j]=='n') n_counter++;
            else if(temp[j]=='c') c_counter++;
        }
        if(z_counter>0 && n_counter>0 && c_counter==0){
            counter++;
        }
    }
    cout << counter;

    return 0;
}