#include <bits/stdc++.h>
#define fi first
#define sc second
#define forn(i,p,k) for(int i=(p);i<=(k);++i)
#define pb push_back
#define mp make_pair
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int baza=(1<<20);
char T[baza<<1];
void Add(int p, int k, const char &v)
{
for(p+=baza-1,k+=baza+1;p+1!=k;p>>=1,k>>=1)
{
if((p&1)==0) T[p+1]|=v;
if((k&1)==1) T[k-1]|=v;
}
}
char Query(int ind)
{
char wyn=0;
for(ind+=baza;ind;ind>>=1) wyn|=T[ind];
return wyn;
}
int main()
{
ios_base::sync_with_stdio(0);
int n,m,l,r,k,wyn=0;
cin>>n>>m;
forn(i,1,m)
{
cin>>l>>r>>k;
Add(l,r,(1<<(k-1)));
}
forn(i,1,n) wyn+=(Query(i)==3);
return cout<<wyn,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 36 37 38 39 40 41 | #include <bits/stdc++.h> #define fi first #define sc second #define forn(i,p,k) for(int i=(p);i<=(k);++i) #define pb push_back #define mp make_pair using namespace std; typedef long long ll; typedef pair<int,int> pii; const int baza=(1<<20); char T[baza<<1]; void Add(int p, int k, const char &v) { for(p+=baza-1,k+=baza+1;p+1!=k;p>>=1,k>>=1) { if((p&1)==0) T[p+1]|=v; if((k&1)==1) T[k-1]|=v; } } char Query(int ind) { char wyn=0; for(ind+=baza;ind;ind>>=1) wyn|=T[ind]; return wyn; } int main() { ios_base::sync_with_stdio(0); int n,m,l,r,k,wyn=0; cin>>n>>m; forn(i,1,m) { cin>>l>>r>>k; Add(l,r,(1<<(k-1))); } forn(i,1,n) wyn+=(Query(i)==3); return cout<<wyn,0; } |
English