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
#include <iostream>
#include <bits/stdc++.h>
using namespace std;

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

    int n, m;
    cin >> n >> m;

    vector<int> tab(n);
    bool fine[3][n];

    while (m--) {
        int l, r, k;
        cin >> l >> r >> k;
        for(int i = l; i <= r; i++)
        {
            if(fine[k-1][i-1] != true)
            {
                tab[i-1] += k;
                fine[k-1][i-1] = true;
            }
        }
    }
    int wyn = 0;

    for(int i = 0; i < n; i++)
        if(tab[i] == 3)
            wyn++;
    cout << wyn;
    return 0;
}