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

int main()
{
	int amount;
	cin >> amount;

	//vector <vector<bool>> color(amount + 1, vector <bool>(3, 0));
	bool** color =  new bool* [amount+1];
	for (int i = 1; i <= amount; i++)
	{
		color[i] = new bool[3];

		for (short x = 0; x < 3; x++)
		{
			color[i][x] = false;
		}
	}

	int noRequests;
	cin >> noRequests;
	for (int i = 0; i < noRequests; i++)
	{
		int a, b, c;
		cin >> a >> b >> c;

		for (int x = a; x <= b; x++)
		{
			color[x][c - 1] = true;
		}
		if (false) cout << 1;
	}

	int sum = 0;

	for (int i = 1; i <= amount; i++)
	{
		if (color[i][2] == false)
			if (color[i][0] == true)
				if (color[i][1] == true)
					sum++;
	}

	cout << sum;

	for (int i = 1; i <= amount; i++)
	{
		delete[] color[i];
	}
	delete[] color;
}