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
50
51
52
53
54
55
#include <iostream>
#include <cstring>

#define YELLOW 1
#define BLUE 2
#define RED 4

int main()
{
	int n, m;
	std::cin >> n >> m;

	char* cans = new char[n];
	memset(cans, 0, n * sizeof(char));

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

		int color = 0;

		switch (k)
		{
		case 1:
			color = YELLOW;
			break;
		case 2:
			color = BLUE;
			break;
		case 3:
			color = RED;
			break;
		}

		for (char* can = cans + l - 1; can != cans + r; can++)
		{
			*can |= color;
		}
	}

	int green = 0;

	for (char* can = cans; can != cans + n; can++)
	{
		if (*can == YELLOW + BLUE)
		{
			green++;
		}
	}

	std::cout << green << std::endl;

	delete[] cans;
}