| 比赛 |
2026.1.3 |
评测结果 |
AAATTTTTTT |
| 题目名称 |
团子大家族 |
最终得分 |
30 |
| 用户昵称 |
梦那边的美好CE |
运行时间 |
7.720 s |
| 代码语言 |
C++ |
内存使用 |
3.95 MiB |
| 提交时间 |
2026-01-03 09:49:45 |
显示代码纯文本
#include<bits/stdc++.h>
#define N 114514
#define mod 998245353
using namespace std;
inline void read(int &x) {bool neg = false;x = 0;char ch = 0;while (ch < '0' || ch > '9') {if (ch == '-') neg = true;ch = getchar();}if (neg) {while (ch >= '0' && ch <= '9') {x = x * 10 + ('0' - ch);ch = getchar();}} else {while (ch >= '0' && ch <= '9') {x = x * 10 + (ch - '0');ch = getchar();}}return;}
template <typename T> inline void write(T x) {if (x < 0) x = -x, putchar('-');if (x > 9) write(x / 10);putchar(x % 10 + 48);}
int C2(int n){//C_n^2
return n*(n-1)/2;
}
int n,m,a[N],f[N],l,r,p,v,x,k,op,ans,cnt;
signed main(){
freopen("seqsqrt.in","r",stdin);freopen("seqsqrt.out","w",stdout);
read(n);read(m);
for(int i=1;i<=n;i++){
read(a[i]);
}
for(int i=1;i<=n;i++){
read(f[i]);
}
while(m--){
read(op);
if(op==1){
read(l);read(r);read(x);
for(int i=l;i<=r;i++)a[i]+=x;
}
if(op==2){
read(p);read(v);
f[p]=v;
}
if(op==3){
read(l);read(r);read(k);
cnt=ans=0;
for(int i=1;i<=n;i++){
cnt+=(f[i]==k);
}
for(int i=l;i<=r;i++){
if(f[i]==k)ans+=a[i];
}ans*=cnt;
write(ans);putchar('\n');
}
}
return 0;
}