为什么双倍经验代码复制来WA了?
查看原帖
为什么双倍经验代码复制来WA了?
1010650
Expert_Dreamer楼主2024/7/6 13:19
#include<bits/stdc++.h>
using namespace std;
int n,m,a[100010],l,r,x;
#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
char buf[1<<23],*p1=buf,*p2=buf,obuf[1<<23],*O=obuf;
inline int read() {
	int x=0,f=1;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-') f=-1;ch=getchar();}
	while(isdigit(ch)) x=x*10+(ch^48),ch=getchar();
	return x*f;
}
namespace QuikIO{
    
    const int size = 1 << 14;
    int p3;
    char out[size];
    
    #define flush() (fwrite(out,1,p3,stdout),p3 = 0)
    #define putchar(ch) (p3 == size && flush(),out[p3++] = ch)
    
    class Flush{public:~Flush(){flush();}}_;
        
    void write(long long x){
        
        if (x > 9) write(x / 10);
        putchar(x % 10 + '0');
        
    }
    
    void print(long long x,char end = '\n'){
        
        write(x);
        putchar(end);
        
    }
    
}using QuikIO::print;
int main(){
    n=read(),m=read();
    for(int i=1;i<=n;i++) a[i]=read();
    while(m--){
        int op;
        op=read(),l=read(),r=read(),x=read();
        if(op==1){
            for(int i=l;i<=r;i++) if(a[i]>x) a[i]-=x;
        }else{
            int ans=0;
            for(int i=l;i<=r;i++) if(a[i]==x) ans++;
            print(ans);
        }
    }
}
2024/7/6 13:19
加载中...