#include<iostream> using namespace std; int main() { int n, m, zielona=0; cin>>n>>m; int l[m], r[m], k[m]; int kol[n][3]; for(int i = 0; i < n; i++) for(int j = 0; j < 3; j++) kol[i][j] = 0; for(int i = 0; i < m; i++) { cin>>l[i]>>r[i]>>k[i]; for(int j = l[i]-1; j < r[i]; j++) kol[j][k[i]-1] = k[i]; } for(int i = 0; i < n; i++) if(kol[i][0] == 1 && kol[i][1] == 2 && kol[i][2] == 0) zielona++; cout<<zielona; return 0; }
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> using namespace std; int main() { int n, m, zielona=0; cin>>n>>m; int l[m], r[m], k[m]; int kol[n][3]; for(int i = 0; i < n; i++) for(int j = 0; j < 3; j++) kol[i][j] = 0; for(int i = 0; i < m; i++) { cin>>l[i]>>r[i]>>k[i]; for(int j = l[i]-1; j < r[i]; j++) kol[j][k[i]-1] = k[i]; } for(int i = 0; i < n; i++) if(kol[i][0] == 1 && kol[i][1] == 2 && kol[i][2] == 0) zielona++; cout<<zielona; return 0; } |