#include <iostream>
using namespace std;
int n, m, a, b, c, ile;
bool t[1000005][3];
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cin>>n>>m;
for (int i=0; i<m; i++) {
cin>>a>>b>>c;
for (int j=a; j<=b; j++) {
t[j][c-1]=1;
}
}
for (int i=0; i<=n; i++) if (t[i][0]==1 && t[i][1]==1 && t[i][2]==0) ile++;
cout<<ile;
}
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | #include <iostream> using namespace std; int n, m, a, b, c, ile; bool t[1000005][3]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin>>n>>m; for (int i=0; i<m; i++) { cin>>a>>b>>c; for (int j=a; j<=b; j++) { t[j][c-1]=1; } } for (int i=0; i<=n; i++) if (t[i][0]==1 && t[i][1]==1 && t[i][2]==0) ile++; cout<<ile; } |
English