#include <iostream>
using namespace std;
struct dorime
{
bool z;
bool n;
bool c;
};
dorime tab[1000001];
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
int n, m, l, r, k, s=0;
cin >> n >> m;
for(int i=1; i<=m; i++)
{
cin >> l >> r >> k;
for(int j=l; j<=r; j++)
{
if(k==1) tab[j].z=1;
if(k==2) tab[j].n=1;
if(k==3) tab[j].c=1;
}
}
for(int i=1; i<=n; i++)
{
if(tab[i].z==1 && tab[i].n==1 && tab[i].c==0) s++;
}
cout << s;
}
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 | #include <iostream> using namespace std; struct dorime { bool z; bool n; bool c; }; dorime tab[1000001]; int main() { ios::sync_with_stdio(false); cin.tie(0); int n, m, l, r, k, s=0; cin >> n >> m; for(int i=1; i<=m; i++) { cin >> l >> r >> k; for(int j=l; j<=r; j++) { if(k==1) tab[j].z=1; if(k==2) tab[j].n=1; if(k==3) tab[j].c=1; } } for(int i=1; i<=n; i++) { if(tab[i].z==1 && tab[i].n==1 && tab[i].c==0) s++; } cout << s; } |
English