36分，普及组该拿的分数：对于每个区间，暴力枚举每条线段，统计颜色数——只有颜色恰好加到1，才算增加一种颜色的线段。

```    for(i=1; i<=m; i++){
ans = 0;
for(j=1; j<=n; j++){
if(x[i]<=l[j] && r[j]<=y[i]){
if(++f[c[j]] == 1) ans++;
}
}
printf("%d\n", ans);
for(j=1; j<=n; j++){
if(x[i]<=l[j] && r[j]<=y[i]) --f[c[j]];
}
}```

```#include <bits/stdc++.h>
#define N 1000005
using namespace std;
int n, m, i, j, k, l, r, c;
int s[N], f[N], ans[N>>2];
struct LR{
int l, r, c, i;
bool operator < (const LR &A) const{
if(r != A.r) return r < A.r;
return c > A.c;
}
} d[N*5];
void jia(int i, int x){
while(i < N) s[i] += x, i += -i&i;
}
int he(int i){
int c = 0;
while(i) c += s[i], i -= -i&i;
return c;
}
int main(){
scanf("%d%d", &n, &m);
for(i=1; i<=n; i++){
scanf("%d%d%d", &d[i].l, &d[i].r, &d[i].c);
}
for(n+=m; i<=n; i++){
scanf("%d%d", &d[i].l, &d[i].r);
d[i].i = i + m - n;
}
sort(d+1, d+n+1);
for(i=1; i<=n; i++){
l = d[i].l, r = d[i].r, c = d[i].c, j = d[i].i;
if(j){
ans[j] = he(r) - he(l-1);
}
else{
if(!f[c]) jia(f[c]=l, 1);
else if(l > f[c]){
jia(f[c], -1);
jia(f[c]=l, 1);
}
}
}
for(i=1; i<=m; i++){
printf("%d\n", ans[i]);
}
return 0;
}```