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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include <iostream>
#include <vector>
#include <map>
using namespace std;
void print(int* tab){
	for(int i=0;i<sizeof(tab)/sizeof(tab[0]);i++){
		cout<<tab[i]<<"\n";
	}
}

int main(){
	int n;
	int m;
	int l,r,k;
	int count = 0;
	cin >> n;
	cin >> m;
	map<int, vector<int>> map;
	for(int i=0;i<n;i++){
		vector<int> vect;
		map[i] = vect;
	}
	for(int i=0;i<m;i++){
		cin>>l;
		cin>>r;
		cin>>k;
		for(int j=l-1; j <r; j++){
			map[j].push_back(k);
		}
	}
	for(auto const& it : map ){
		bool yel = false;
		bool blu = false;
		bool got = true;
		for(const auto i: it.second){
			//cout<< it.first << "\t" << i << "\n";
			if(i == 1) yel = true;
			else if(i == 2) blu = true;
			else{
				got = false;
				break;
			}
		}
		if(blu == true && yel == true && got == true){
			count++;
		}
	}
	cout << count;
}