提交记录 9628
提交时间 |
评测时间 |
2019-06-20 22:23:19 |
2020-08-01 01:41:45 |
#include<algorithm>
#include<cstdio>
#define F dp[i+1][p][l]
using namespace std;
const int mod=1e9+7;
int n,m,s,x,y,mn,mx,num,ans,dp[10][550][10];
int pow(int k,int i)
{
int t=1;
while(i)
{
if(i&1) t=1ll*t*k%mod;
k=1ll*k*k%mod;i>>=1;
}
return t;
}
int main()
{
scanf("%d%d",&n,&m);
if(n>m) swap(n,m);
mn=min(n+1,m);s=(1<<n-1)-1;
for(int i=0;i<(1<<n);++i) dp[1][i][0]=1;
for(int i=1;i<mn;++i)
for(int j=0;j<(1<<n);++j)
for(int k=0;k<n;++k)
if(dp[i][j][k])
for(int p=0,l;p<(1<<n);++p)
{
if(((j>>1)&p)!=(p&s)) continue;
if(k&&((j>>n-k+1)!=((p>>n-k)&((1<<k-1)-1)))) continue;
l=n-1;
for(;l>k;--l)
if(((j>>n-l)&1)==((p>>n-l-1)&1))
break;
F+=dp[i][j][k];
if(F>=mod) F-=mod;
}
for(int i=0;i<(1<<n);++i)
for(int j=0;j<n;++j)
{
ans+=dp[mn][i][j];
if(ans>=mod) ans-=mod;
}
printf("%d\n",1ll*ans*pow(3-(n==1),m-mn)%mod);
return 0;
}
Compilation | N/A | N/A | Compile OK | Score: N/A | 显示更多 |
Testcase #1 | 9.44 us | 28 KB | Accepted | Score: 5 | 显示更多 |
Testcase #2 | 13.04 us | 28 KB | Accepted | Score: 5 | 显示更多 |
Testcase #3 | 13.91 us | 32 KB | Accepted | Score: 5 | 显示更多 |
Testcase #4 | 12.22 us | 36 KB | Accepted | Score: 5 | 显示更多 |
Testcase #5 | 10.49 us | 32 KB | Accepted | Score: 5 | 显示更多 |
Testcase #6 | 9.67 us | 32 KB | Accepted | Score: 5 | 显示更多 |
Testcase #7 | 9.82 us | 32 KB | Accepted | Score: 5 | 显示更多 |
Testcase #8 | 9.76 us | 32 KB | Accepted | Score: 5 | 显示更多 |
Testcase #9 | 10.78 us | 32 KB | Accepted | Score: 5 | 显示更多 |
Testcase #10 | 9.3 us | 32 KB | Accepted | Score: 5 | 显示更多 |
Testcase #11 | 11.63 us | 40 KB | Accepted | Score: 5 | 显示更多 |
Testcase #12 | 11.92 us | 40 KB | Accepted | Score: 5 | 显示更多 |
Testcase #13 | 10.91 us | 40 KB | Accepted | Score: 5 | 显示更多 |
Testcase #14 | 72.77 us | 68 KB | Accepted | Score: 5 | 显示更多 |
Testcase #15 | 189.83 us | 84 KB | Accepted | Score: 5 | 显示更多 |
Testcase #16 | 582.16 us | 132 KB | Accepted | Score: 5 | 显示更多 |
Testcase #17 | 663.52 us | 148 KB | Accepted | Score: 5 | 显示更多 |
Testcase #18 | 667.19 us | 148 KB | Accepted | Score: 5 | 显示更多 |
Testcase #19 | 663.73 us | 148 KB | Accepted | Score: 5 | 显示更多 |
Testcase #20 | 665.52 us | 148 KB | Accepted | Score: 5 | 显示更多 |
Judge Duck Online | 评测鸭在线
Server Time: 2024-12-05 10:42:37 | Loaded in 1 ms | Server Status
个人娱乐项目,仅供学习交流使用 | 捐赠