#include <iostream>
using namespace std;
int x, y, wyn;
bool cos[4][100010];
int main(){
cin>>x>>y;
for(int i=0; i<y; i++)
{
int a, b, c;
cin>>a>>b>>c;
for(int j=a; j<=b; j++)
cos[c][j]=1;
}
for(int i=0; i<=x; i++)
if(cos[1][i]==1&&cos[2][i]==1&&cos[3][i]==0)
wyn++;
cout<<wyn;
}
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 | #include <iostream> using namespace std; int x, y, wyn; bool cos[4][100010]; int main(){ cin>>x>>y; for(int i=0; i<y; i++) { int a, b, c; cin>>a>>b>>c; for(int j=a; j<=b; j++) cos[c][j]=1; } for(int i=0; i<=x; i++) if(cos[1][i]==1&&cos[2][i]==1&&cos[3][i]==0) wyn++; cout<<wyn; } |
English