#include <iostream> #include <vector> using namespace std; int main(){ int n, m; cin >> n >> m; vector <bool[3]> tab(n); int a, b, c; while (m--) { cin >> a >> b >> c; c--; for (int i = a - 1; i < b; i++) tab[i][c] = true; } c = 0; for (auto &i : tab) if (i[0] && i[1] && !i[2]) c++; cout << c; return 0; }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | #include <iostream> #include <vector> using namespace std; int main(){ int n, m; cin >> n >> m; vector <bool[3]> tab(n); int a, b, c; while (m--) { cin >> a >> b >> c; c--; for (int i = a - 1; i < b; i++) tab[i][c] = true; } c = 0; for (auto &i : tab) if (i[0] && i[1] && !i[2]) c++; cout << c; return 0; } |