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
#include <bits/stdc++.h>

using namespace std;

struct color {
  bool yellow;
  bool blue;
  bool red;
};

int main () {
  int buckets,mixes;
  cin>>buckets>>mixes;
  color arr [buckets] = {{false,false,false},{false,false,false}};
  for (size_t j = 0; j < mixes; j++) {
    int start,end,color;
    cin>>start>>end>>color;
    for (size_t i = --start; i < end; i++) {
      if(color==1) {
        arr[i].yellow=true;
      } else if (color==2) {
        arr[i].blue=true;
      } else if (color==3) {
        arr[i].red=true;
      }
    }
  }

  int green=0;

  for (size_t i = 0; i < buckets; i++) {
    if (arr[i].yellow&&arr[i].blue&&!arr[i].red) {
      green++;
    }
  }
  cout<<green;
}