#include <bits/stdc++.h>
using namespace std;
bool tab [1000010][5];
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int t, puszki, wynik=0;
cin>>puszki>>t;
int l, r, k;
for(int i=0; i<t; i++){
cin>>l>>r>>k;
for(int j=l; j<=r; j++){
tab[j][k] = 1;
}
//cout<<i<< " "<<t<<endl;
}
for(int i=1; i<=puszki; i++){
if((tab[i][1] and tab[i][2]) and !tab[i][3]){
wynik++;
}
}
cout<<wynik;
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 | #include <bits/stdc++.h> using namespace std; bool tab [1000010][5]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int t, puszki, wynik=0; cin>>puszki>>t; int l, r, k; for(int i=0; i<t; i++){ cin>>l>>r>>k; for(int j=l; j<=r; j++){ tab[j][k] = 1; } //cout<<i<< " "<<t<<endl; } for(int i=1; i<=puszki; i++){ if((tab[i][1] and tab[i][2]) and !tab[i][3]){ wynik++; } } cout<<wynik; return 0; } |
English