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

using namespace std;

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    int n, m, counter = 0;
    cin >> n >> m;
    string container[n];
    for (int i = 0; i != m; i++) {
        int start, end, val;
        char new_val;
        cin >> start >> end >> val;
        if (val == 1) new_val = 'z';
        else if (val == 2) new_val = 'n';
        else new_val = 'c';
        for (int j = start - 1; j != end; j++) {
            if (!(count(container[j].begin(), container[j].end(), new_val))) {
                container[j] += new_val;
            }
        }
    }
    for (auto const& s : container) {
        if (s == "zn" || s == "nz") counter++;
    }
    cout << counter;
}