#include <bits/stdc++.h>
using namespace std;
int t[1000007][4];
int main(){
ios_base::sync_with_stdio(false);
int n,m;
cin >> n >> m;
int _,__,___;
for (int i = 0; i < m; ++i){
cin >> _ >> __ >> ___;
++t[_][___];
--t[__+1][___];
}
int k1=0,k2=0,k3=0;
int w=0;
for (int i = 1; i <= n; ++i){
k1+=t[i][1];
k2+=t[i][2];
k3+=t[i][3];
if(k1>0&&k2>0&&k3==0)++w;
}
cout << w << "\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 | #include <bits/stdc++.h> using namespace std; int t[1000007][4]; int main(){ ios_base::sync_with_stdio(false); int n,m; cin >> n >> m; int _,__,___; for (int i = 0; i < m; ++i){ cin >> _ >> __ >> ___; ++t[_][___]; --t[__+1][___]; } int k1=0,k2=0,k3=0; int w=0; for (int i = 1; i <= n; ++i){ k1+=t[i][1]; k2+=t[i][2]; k3+=t[i][3]; if(k1>0&&k2>0&&k3==0)++w; } cout << w << "\n"; return 0; } |
English