#include <iostream>
#include <vector>
using namespace std;
int main(){
int n,m,l,r,k,licz=0;
cin>>n>>m;
bool **t=new bool *[n];
for(int i=0;i<n;i++){
t[i]=new bool [3];
for(int j=0;j<3;j++){
t[i][j]=0;
}
}
for(int i=0;i<m;i++){
cin>>l>>r>>k;
for(int j=l-1;j<r;j++){
t[j][k-1]=1;
}
}
for(int i=0;i<n;i++){
if(t[i][0]==1){
if(t[i][1]==1 && t[i][2]==0){
licz++;
}
}
delete [] t[i];
}
delete [] t;
cout<<licz;
}
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 31 32 | #include <iostream> #include <vector> using namespace std; int main(){ int n,m,l,r,k,licz=0; cin>>n>>m; bool **t=new bool *[n]; for(int i=0;i<n;i++){ t[i]=new bool [3]; for(int j=0;j<3;j++){ t[i][j]=0; } } for(int i=0;i<m;i++){ cin>>l>>r>>k; for(int j=l-1;j<r;j++){ t[j][k-1]=1; } } for(int i=0;i<n;i++){ if(t[i][0]==1){ if(t[i][1]==1 && t[i][2]==0){ licz++; } } delete [] t[i]; } delete [] t; cout<<licz; } |
English