The Ghost Type

Here is the link of the above problem i have been trying. Just want to know where i am going wrong with my this code?
#include<bits/stdc++.h>
using namespace std;
int n;
int getcount(int mask){
if(mask== (1<<(n)-1))
return 1;
int count=0;
for(int i=0;i<n;i++){
if(!mask&(1<<i)){
for(int j=1; j<=n; j++){
if(!mask&(1<<(j-1)) && (i+1)&(j)==(i+1))
if(getcount(mask|(1<<i)))
count++ ;
}
}
}
return count;
}
int main(){

cin>>n;

cout<<getcount(0)<<endl;

return 0;

}
please help me with the above one.