#include <bits/stdc++.h>
using namespace std;
int t[1000010][4];
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
int n,m,i,j,l,r,k,xd[4]={0,0,0,0},w=0;
cin >> n >> m;
for(i=1; i<=m; i++)
{
cin >> l >> r >> k;
t[l][k]++;
t[r+1][k]--;
}
for(i=1; i<=n; i++)
{
for(j=1; j<=3; j++) xd[j]+=t[i][j];
if(xd[1] && xd[2] && !xd[3])
w++;
}
cout << w;
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 33 34 35 | #include <bits/stdc++.h> using namespace std; int t[1000010][4]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n,m,i,j,l,r,k,xd[4]={0,0,0,0},w=0; cin >> n >> m; for(i=1; i<=m; i++) { cin >> l >> r >> k; t[l][k]++; t[r+1][k]--; } for(i=1; i<=n; i++) { for(j=1; j<=3; j++) xd[j]+=t[i][j]; if(xd[1] && xd[2] && !xd[3]) w++; } cout << w; return 0; } |
English