萌新求助,第5个点RE
查看原帖
萌新求助,第5个点RE
341049
xtracer楼主2021/1/26 08:28
#include<iostream>
#include<cstdio>
#include<cstring>
namespace xtracer{
    typedef long long ll;
    void read(ll &n){
        ll x=0,f=1;
        char ch=getchar();
        while(ch<'0' or ch>'9'){
            if(ch=='-')f=-1;
            ch=getchar();
        }
        while(ch>='0' and ch<='9'){
            x=x*10+ch-48;
            ch=getchar();
        }
        n=x*f;
    }
    void write(ll n){
        if(n>=10)write(n/10);
        putchar(n%10+48);
    }
}
using namespace xtracer;
using std::fill;
ll bucket[100001]={};
ll test;
ll x;
ll n;
ll ans;
int main(){
    read(test);
    for(ll i=1;i<=test;i++){
        read(n);
        ans=0;
        memset(bucket,0,sizeof(bucket));
        for(ll j=1;j<=n;j++){
            read(x);
            if(bucket[x]==0){
                bucket[x]=1;
                ans+=1;
            }
            else if(bucket[x+1]==0){
                bucket[x+1]=1;
                ans+=1;
            }
            else continue;
            x=0;
        }
        n=0;
        write(ans);
        putchar('\n');
    }
    return 0;
}

这段代码老是出错,说"Exit code=-1073741819",我看不出来有啥问题,求助大佬qaq

2021/1/26 08:28
加载中...