提交时间:2023-08-16 12:12:37
运行 ID: 98651
#include<bits/stdc++.h> using namespace std; const int N=1e5+9; int n,m,a[N]; map<int,int> mp; int q[N],top; int main() { // freopen("karry5307.in","r",stdin); // freopen("karry5307.out","w",stdout); ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin>>n>>m; for(int i=1;i<=n;i++) { cin>>a[i]; } while(m--) { int opt; cin>>opt; if(opt==1) { int l,r,x; cin>>l>>r>>x; for(int i=l;i<=r;i++) a[i]=x; } else { int l,r; cin>>l>>r; top=0; for(int i=l;i<=r;i++) if(mp[a[i]]==0) { mp[a[i]]=1; q[++top]=a[i]; } cout<<top<<'\n'; while(top) { mp[q[top]]=0; top--; } } } return 0; }