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

using namespace std;

string l2c(int x){
    if(x == 1) return "Zolty";
    if(x == 2) return "Niebieski";
    if(x == 3) return "Czerwony";
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); 
    int n, m;
    cin >> n >> m;
    vector<string> tab(n, "Bialy");
    while(m--){
        int l, r, k;
        cin >> l >> r >> k;
        for(int i = l-1; i < r; i++){
            if(tab[i] == "Bialy") tab[i] = l2c(k);
            if(tab[i] != "Bialy"){
                if(k == 1){
                    if(tab[i] == "Niebieski") tab[i] = "Zielony";
                    if(tab[i] == "Czerwony") tab[i] = "Pomaranczowy";
                    if(tab[i] == "Fioletowy") tab[i] = "Brazowy";
                }
                if(k == 2){
                    if(tab[i] == "Zolty") tab[i] = "Zielony";
                    if(tab[i] == "Czerwony") tab[i] = "Fioletowy";
                    if(tab[i] == "Pomaranczowy") tab[i] = "Brazowy";
                }
                if(k == 3){
                    if(tab[i] == "Zolty") tab[i] = "Pomaranczowy";
                    if(tab[i] == "Niebieski") tab[i] = "Fioletowy";
                    if(tab[i] == "Zielony") tab[i] = "Brazowy";
                }
            }
        }
    }
    int wynik = 0;
    for(int i = 0; i < n; i++){
        if(tab[i] == "Zielony") wynik = wynik + 1;
    }
    
    cout << wynik;
    return 0;
}