1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include<iostream>
using namespace std;
int main()
{
    int n, m, i, j, l, r, k, counter = 0;
    cin >> n >> m;
    int colors[n + 1][4] = {0};
    for (i = 0; i < m; i++)
    {
        cin >> l >> r >> k;
        for (j = l; j <= r; j++)
        {
            colors[j][k]++;
        }
    }
    for (i = 1; i <= n; i++)
    {
        if (colors[i][3] == 0 && colors[i][1] > 0 && colors[i][2] > 0) counter++;
    }
    cout<<counter;

    return 0;
}