1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include <iostream>
using namespace std;

int main()
{
	int n,m,l,r,k,count=0;
	scanf(" %i %i",&n,&m);
	unsigned int* args = new unsigned int[n] {0};
	for (int x = 0; x < m; x++)
	{
		scanf(" %i %i %i",&l,&r,&k);
		for (int i = l-1; i <= r-1; i++)
		{
			args[i] = args[i] | (1 << (k-1));
			if (args[i] == 3)
				count++;
			if (args[i] == 7)
				count--;
		}
	}
		printf("%i", count);
	}