This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const LL MOD=1000000007;
LL dp[(1<<20)][20][2];
int main(){
ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
LL n,s,t;
cin >> n >> s >> t;
s--;t--;
dp[(1<<s)][s][0]=1;
dp[(1<<s)][s][1]=1;
for(LL i=0;i<(1<<n);i++){
for(LL j=0;j<n;j++){
if(i & (1<<j)){
for(LL k=0;k<n;k++){
if(!(i & (1<<k))){
if(j>k)dp[i+(1<<k)][k][0]=(dp[i+(1<<k)][k][0]+dp[i][j][1])%MOD;
else dp[i+(1<<k)][k][1]=(dp[i+(1<<k)][k][1]+dp[i][j][0])%MOD;
}
}
}
}
}
cout << (dp[(1<<n)-1][t][0]+dp[(1<<n)-1][t][1])%MOD << endl;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |