#include <iostream> #include <cstring> int main() { std::ios::sync_with_stdio(false); std::cin.tie(nullptr); unsigned int n, m; std::cin >> n >> m; auto colours = new uint_fast8_t[n]; std::memset(colours, 0, sizeof(n)); for (auto i = 0u; i < m; ++i) { unsigned int l, r, k; std::cin >> l >> r >> k; for (auto j = l - 1; j < r; ++j) { colours[j] |= (k == 3 ? 4 : k); } } auto counter = 0u; for (auto i = 0u; i < n; ++i) { if (colours[i] == 3) ++counter; } std::cout << counter << "\r\n"; delete[] colours; }
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 <iostream> #include <cstring> int main() { std::ios::sync_with_stdio(false); std::cin.tie(nullptr); unsigned int n, m; std::cin >> n >> m; auto colours = new uint_fast8_t[n]; std::memset(colours, 0, sizeof(n)); for (auto i = 0u; i < m; ++i) { unsigned int l, r, k; std::cin >> l >> r >> k; for (auto j = l - 1; j < r; ++j) { colours[j] |= (k == 3 ? 4 : k); } } auto counter = 0u; for (auto i = 0u; i < n; ++i) { if (colours[i] == 3) ++counter; } std::cout << counter << "\r\n"; delete[] colours; } |