#include <bits/stdc++.h>
using namespace std;
long long int x,y,z,a,b,n,m,t[1000007][4],w;
int main()
{
cin>>n>>m;
for(a=0; a<m; a++){
cin>>x>>y>>z;
for(b=x; b<=y; b++){
t[b][z]=1;//cout<<b<<" "<<z<<" "<<t[b][z]<<"\n";
}
}
for(b=1; b<=n; b++){
//cout<<t[b][1]<<t[b][2]<<t[b][3]<<"\n";
if(t[b][1]==1&&t[b][2]==1&&t[b][3]==0){
w++;
}
}
cout<<w<<"\n";
}
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | #include <bits/stdc++.h> using namespace std; long long int x,y,z,a,b,n,m,t[1000007][4],w; int main() { cin>>n>>m; for(a=0; a<m; a++){ cin>>x>>y>>z; for(b=x; b<=y; b++){ t[b][z]=1;//cout<<b<<" "<<z<<" "<<t[b][z]<<"\n"; } } for(b=1; b<=n; b++){ //cout<<t[b][1]<<t[b][2]<<t[b][3]<<"\n"; if(t[b][1]==1&&t[b][2]==1&&t[b][3]==0){ w++; } } cout<<w<<"\n"; } |
English