#include<bits/stdc++.h>
using namespace std;
int a,b,n,m,i,j,kolor,p,k,odp;
int tab [1010101][3];
int main ()
{
ios_base::sync_with_stdio(false);
cin>>n>>m;
for (i=1;i<=m;i++)
{
cin>>p>>k>>kolor;
kolor--;
tab[p][kolor]++;
tab[k+1][kolor]--;
}
for (i=1;i<=n;i++)
{
for (j=0;j<3;j++)
{
tab[i+1][j]+=tab[i][j];
}
if (tab[i][0]>0 && tab[i][1]>0 && tab[i][2]==0)
{
odp++;
}
}
cout<<odp<<'\n';
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 | #include<bits/stdc++.h> using namespace std; int a,b,n,m,i,j,kolor,p,k,odp; int tab [1010101][3]; int main () { ios_base::sync_with_stdio(false); cin>>n>>m; for (i=1;i<=m;i++) { cin>>p>>k>>kolor; kolor--; tab[p][kolor]++; tab[k+1][kolor]--; } for (i=1;i<=n;i++) { for (j=0;j<3;j++) { tab[i+1][j]+=tab[i][j]; } if (tab[i][0]>0 && tab[i][1]>0 && tab[i][2]==0) { odp++; } } cout<<odp<<'\n'; return 0; } |
English