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