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
#include <iostream>
using namespace std;

int a[4];
int e[1000006][4];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n, m;
    cin >> n >> m;
    int ans = 0;
    while (m--)
    {
        int l, r, k;
        cin >> l >> r >> k;
        e[l][k]++;
        e[r + 1][k]--;
    }
    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j <= 3; j++)
        {
            a[j] += e[i][j];
        }
        if (a[1] > 0 && a[2] > 0 && a[3] == 0) ans++;
    }
    cout << ans;
}