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
#include <iostream>
using namespace std;

struct kolory {
	bool zolty;
	bool niebieski;
	bool czerwony;
};

int main()
{
	int n, m;
	cin >> n >> m;
	kolory *t = new kolory[n];
	for (int i = 0;i < n;i++)
	{
		t[i].zolty = 0;
		t[i].niebieski = 0;
		t[i].czerwony = 0;
	}
	int a, b, c;
	for (int i = 0;i < m;i++)
	{
		cin >> a >> b >> c;
		for (int j = a-1;j <= b-1;j++)
		{
			if (c == 1) t[j].zolty = 1;
			if (c == 2) t[j].niebieski = 1;
			if (c == 3) t[j].czerwony = 1;
		}
	}
	int wyn = 0;
	for (int i = 0;i <n;i++)
	{
		if (t[i].zolty ==1 && t[i].niebieski ==1 && t[i].czerwony == 0) wyn++;
	}
	cout << wyn;
}