// Andrzej Radzik #include <iostream> int main() { std::cin.tie(0); short array [ 100001 ]; int n; int m; int l; int r; short k; int i; int j; int count = 0; std:: cin >> n >> m; for ( i = 1; i <= n; ++i ) { array[ i ] = 0; } for ( i = 0; i < m; ++i ) { std::cin >> l >> r >> k; if ( k == 3 ) k = 4; for ( j = l; j <= r; ++j ) { array[ j ] |= k; } } for ( i = 1; i <= n; ++i ) { if ( array[ i ] == 3 ) count++; } std::cout << count << std::endl; return 0; }
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 | // Andrzej Radzik #include <iostream> int main() { std::cin.tie(0); short array [ 100001 ]; int n; int m; int l; int r; short k; int i; int j; int count = 0; std:: cin >> n >> m; for ( i = 1; i <= n; ++i ) { array[ i ] = 0; } for ( i = 0; i < m; ++i ) { std::cin >> l >> r >> k; if ( k == 3 ) k = 4; for ( j = l; j <= r; ++j ) { array[ j ] |= k; } } for ( i = 1; i <= n; ++i ) { if ( array[ i ] == 3 ) count++; } std::cout << count << std::endl; return 0; } |