Run ID 作者 问题 语言 测评结果 分数 时间 内存 代码长度 提交时间
98613 CSYZ_WanYL Karry5307 C++ 运行超时 10 1000 MS 2720 KB 1317 2023-08-16 12:08:41

Tests(2/6):


#include<bits/stdc++.h> using namespace std; const int N=1e5+5; int n,m; int a[N]; int b[N],tot; bool vis[N]; struct node{ int opt,lt,rt,k; }q[N]; int main(){ // freopen("karry5307.in","r",stdin); // freopen("karry5307.in","w",stdin); ios::sync_with_stdio(false); // cin.tie(0);cout.tie(0); 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].opt>>q[i].lt>>q[i].rt; // cout<<q[i].opt<<" "<<q[i].lt<<" "<<q[i].rt<<" "; if(q[i].opt==1){ cin>>q[i].k; // cout<<q[i].k<<" "; b[++tot]=q[i].k; } // cout<<"\n"; } // for(int i=1;i<=m;i++){ // cout<<q[i].opt<<" "<<q[i].lt<<" "<<q[i].rt<<" "; // if(q[i].opt==1) cout<<q[i].k<<" "; // cout<<"\n"; // } 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; // cout<<a[i]<<" "; } for(int x=1;x<=m;x++){ if(q[x].opt==1){ q[x].k=lower_bound(b+1,b+tot+1,q[x].k)-b; for(int i=q[x].lt;i<=q[x].rt;i++) a[i]=q[x].k; } else if(q[x].opt==2){ int sum=0; for(int i=1;i<=tot;i++) vis[i]=false; for(int i=q[x].lt;i<=q[x].rt;i++){ // cout<<a[i]<<" "; if(vis[a[i]]==false){ vis[a[i]]=true; sum++; } } cout<<sum<<"\n";; } } return 0; }


测评信息: