提交时间:2023-08-16 14:21:25
运行 ID: 98780
#include<bits/stdc++.h> using namespace std; const int N=2e5+5; int n,m; int a[N]; int b[N],tot; int buc[N]; struct node{ int lt,rt,k; }q[N]; //排序?什么排序?mutable 是什么?我又是什么? //我为什么坐在这里?为什么在写着这一份代码? //为什么我要自讨苦吃,我又不玩黄盖 //请鞭笞我吧 //为什么我要说上面这句话 //为什么我要开T1 int main(){ // freopen("ODT.in","r",stdin); // froepen("ODT.out","w",stdout); ios::sync_with_stdio(false); cin>>n>>m; for(int i=1;i<=n;i++){ cin>>a[i]; b[++tot]=a[i]; } for(int i=1;i<=m;i++){ cin>>q[i].lt>>q[i].rt>>q[i].k; b[++tot]=q[i].k; } sort(b+1,b+tot+1); tot=unique(b+1,b+tot+1)-b-1; for(int i=1;i<=n;i++) a[i]=lower_bound(b+1,b+tot+1,a[i])-b; for(int x=1;x<=m;x++){ q[x].k=lower_bound(b+1,b+tot+1,q[x].k)-b; for(int i=1;i<=tot;i++) buc[i]=0; for(int i=q[x].lt;i<=q[x].rt;i++){ buc[a[i]]++; a[i]=q[x].k; } cout<<buc[q[x].k]<<"\n"; } return 0; } //场推珂朵莉?