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

int main(void) {
  int n = 0;
  int m = 0;
  int li = 0;
  int ri = 0;
  int ki = 0;
  int counter = 0;
  int licznik = 0;
  std::cin >> n >> m;

  struct puszki {
    bool yellow = 0;
    bool blue = 0;
    bool red = 0;
  };

  puszki tab[n+1] = {0,0};

  while (std::cin >> li >> ri >> ki) {
    for (size_t i = li; i <= ri; i++) {
      if (ki == 1) {
        tab[i].yellow = 1;
      }
      else if (ki == 2) {
        tab[i].blue = 1;
      }
      else if (ki == 3) {
        tab[i].red = 1;
      }
    }
  }
  for (size_t i = 1; i <= n; i++) {
    if (tab[i].yellow == 1 && tab[i].blue == 1 && tab[i].red == 0) {
      licznik++;
    }
  }
  std::cout << licznik << '\n';
  return 0;
}