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
#include <iostream>
#include <vector>

using namespace std;

int main()
{
	int n, m, l, r, k, ile = 0;

	cin >> n >> m;

	bool* yell = new bool[n]();
	bool* blue = new bool[n]();
	bool* red = new bool[n]();

	for (int i = 0; i < m; i++)
	{
		cin >> l >> r >> k;

		for (int j = l; j <= r; j++)
		{
			switch (k)
			{
			case 1:
				yell[j - 1] = true;
				break;
			case 2:
				blue[j - 1] = true;
				break;
			case 3:
				red[j - 1] = true;
				break;
			}
		}
	}

	for (int i = 0; i < n; i++)
	{
		if (yell[i] && blue[i] && !red[i]) ile++;
	}

	cout << ile;

	return 0;
}