这个代码CE&RE了,求助大佬
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,k,S[20],v[20],ans;
bool s[20]={0};
ll read()
{
ll x=0;
char c;
for(c=getchar();c>='0' && c<='9';c=getchar())
{
x=(x<<1)+(x<<3)+c-'0';
}
return x;
}
void dfs(ll a[],ll way,bool visit[])
{
if(way==n)
{
ans++;
return;
}
for(ll i=0;i<n;i++)
{
if(way>0 && abs(S[i]-a[way-1])>k && (!visit[i])){
a[way]=S[i];
visit[i]=1;
dfs(a,way+1,visit);
visit[i]=0;
}
else if(way==0)
{
a[way]=S[i];
visit[i]=1;
dfs(a,way+1,visit);
visit[i]=0;
}
}
return;
}
int main()
{
// freopen("emmm.in","r",stdin);
// freopen("emmm.out","w",stdout);
n=read();
k=read();
for(ll i=0;i<n;i++)
{
S[i]=read();
}
dfs(v,0,s);
cout<<ans<<endl;
return 0;
}