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

using namespace std;

int n, m,st,en,ko,wynik;


int main()
{

    cin >> n;
    cin >> m;
  int tab[n][3];

      for (int i = 0; i < n; i++)
    {
        for ( int t=0;t<3;t++)
            tab[i][t]=0;
    }
    for (int i = 0; i < m; i++)
    {
        cin >> st >> en >> ko;
        for (int z = st - 1; z < en; z++)
        {
            if (ko == 1)
                tab[z][0] = 1;
            else if (ko == 2)
                tab[z][1] = 1;
            else if (ko == 3)
                tab[z][2] = 1;


        }
    }
    for (int i = 0; i < n; i++)
    {

        if ((tab[i][0] == 1)&& (tab [i][1]==1)&& (tab[i][2]==0))
            wynik++;
    }


    cout << wynik;


}