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

int main() {
    int cansNum, operations, left, right;
    short color;
    std::cin >> cansNum >> operations;
    unsigned short cans[cansNum];
    for (int i = 0; i < cansNum; i++) {
        cans[i] = 0;
    }

    for (int i = 0; i < operations; i++) {
        std::cin >> left >> right >> color;

        for (int j = left - 1; j < right; j++) {
            cans[j] = cans[j] | (1 << color - 1);
        }
    }

    int cansWithGreen = 0;
    for (int i = 0; i < cansNum; i++) {
        if (cans[i] == 3) {
            cansWithGreen++;
        }
    }

    std::cout << cansWithGreen;
    
    return 0;
}