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
#include <bits/stdc++.h>
using namespace std;
#define h 1000100
int fa[4][h];
int main()
{
   ios_base::sync_with_stdio(0);
   int n, m; cin>>n>>m;
   while (m--)
   {
       int a, b, c; cin>>a>>b>>c;
       fa[c][a]++; fa[c][b+1]--;
   }
   for (int i=1;i<=3;i++)
   {
       int sum=0;
       for (int k=1;k<=n;k++)
       {
           sum+=fa[i][k];
           fa[i][k]=sum;
       }
   }
   int res=0;
   for (int k=1;k<=n;k++)
   {
       if ( fa[1][k]>0 && fa[2][k]>0 && fa[3][k]==0 ) res++;
   }
   cout<<res;




  return 0;
}