#include<bits/stdc++.h> using namespace std; #define magiczne ios_base::sync_with_stdio(0); #define linijki cin.tie(0); int n, m, l, r, k, red, yellow, blue, dye[1000007][3], result; int main() { magiczne linijki for (cin >> n >> m; m--;) { cin >> l >> r >> k; dye[--l][--k]++; dye[r][k]--; } for (int i = 0; i < n; ++i) { yellow += dye[i][0]; blue += dye[i][1]; red += dye[i][2]; if (yellow && blue && !red) result++; } cout << result; 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 | #include<bits/stdc++.h> using namespace std; #define magiczne ios_base::sync_with_stdio(0); #define linijki cin.tie(0); int n, m, l, r, k, red, yellow, blue, dye[1000007][3], result; int main() { magiczne linijki for (cin >> n >> m; m--;) { cin >> l >> r >> k; dye[--l][--k]++; dye[r][k]--; } for (int i = 0; i < n; ++i) { yellow += dye[i][0]; blue += dye[i][1]; red += dye[i][2]; if (yellow && blue && !red) result++; } cout << result; return 0; } |