#include <iostream>
#include <cstdio>
const int M1 = 1000001;
struct Can {
bool yellow, blue, red, green;
};
Can arr[M1];
int main() {
int n, m, l, r, c, out;
scanf("%d%d", &n, &m);
for(int i = 0; i < m; i++) {
scanf("%d%d%d", &l, &r, &c);
for(int j = l; j <= r; j++) {
if(c == 1) arr[j].yellow = true;
else if(c == 3) arr[j].blue = true;
else arr[j].red = true;
}
}
for(int i = 1; i <= n; i++) {
if(arr[i].yellow == true && arr[i].blue == true && arr[i].red == false)
out++;
}
printf("%d", out);
}
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 <cstdio> const int M1 = 1000001; struct Can { bool yellow, blue, red, green; }; Can arr[M1]; int main() { int n, m, l, r, c, out; scanf("%d%d", &n, &m); for(int i = 0; i < m; i++) { scanf("%d%d%d", &l, &r, &c); for(int j = l; j <= r; j++) { if(c == 1) arr[j].yellow = true; else if(c == 3) arr[j].blue = true; else arr[j].red = true; } } for(int i = 1; i <= n; i++) { if(arr[i].yellow == true && arr[i].blue == true && arr[i].red == false) out++; } printf("%d", out); } |
English