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
#include <iostream>
int main()
{
	int n, m;
	int **p;
	std::cin >> n >> m;
	int** operations = new int*[m];
	for(int i=0;i<m;i++){
		operations[i] = new int[3];
		std::cin >> operations[i][0] >> operations[i][1] >> operations[i][2];			
	}	
	p = new int* [n];
	for(int i=0;i<n;i++){
		p[i] = new int[3];
		p[i][0] = 0;
		p[i][1] = 0;
		p[i][2] = 0;
	}
	for (int i = 0; i < m; i++){
		for(int j=operations[i][0]-1;j<operations[i][1];j++){
			p[j][operations[i][2]-1]++;
		}
	}
	m = 0;
	for (int i = 0; i < n; i++){
		if (p[i][0] > 0 && p[i][1] > 0 && p[i][2] == 0) m++;
	}
	std::cout << m;
	return 0;
}