提交时间:2023-08-16 12:10:31
运行 ID: 98639
#include<bits/stdc++.h> using namespace std; const int N=200011; #define int long long #define mod 1000000007 int t,n,k,m; //map<int,int> q; int a[N]; unordered_map<int,int> q; signed main(){ // freopen("ssh.in","r",stdin); // freopen("ssh.in","w",stdout); cin>>n>>m; for(int i=1;i<=n;i++)cin>>a[i]; for(int i=1;i<=m;i++){ int opt,l,r,x; cin>>opt; int ans=0; if(opt==1){ cin>>l>>r>>x; for(int j=l;j<=r;j++)a[j]=x; } else{ cin>>l>>r; for(int j=l;j<=r;j++){ q[a[j]]++; if(q[a[j]]==1)ans++; } cout<<ans<<endl; for(int j=l;j<=r;j++)q[a[j]]--; } } }