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

int main() {
	int howManyCans, howManyOperations;
	int l, r, color;
	std::cin >> howManyCans >> howManyOperations;

	std::vector<std::vector<bool>> cans;
	for (int i = 0; i < howManyCans; i++) {
		cans.push_back({ 0, 0 ,0 });
	}

	for (int i = 0; i < howManyOperations; i++) {
		std::cin >> l >> r >> color;
		for (int j = l - 1; j <= r - 1; j++) {
			cans[j][color - 1] = 1;
		}
	}

	int result = 0;
	for (int i = 0; i < howManyCans; i++) {
		if (cans[i][0] && cans[i][1] && !cans[i][2]) {
			result++;
		}
	}

	std::cout << result;

	return 0;
}