记录编号 |
418055 |
评测结果 |
AAAAAAAAAA |
题目名称 |
棋盘放車 |
最终得分 |
100 |
用户昵称 |
Regnig Etalsnart |
是否通过 |
通过 |
代码语言 |
C++ |
运行时间 |
0.113 s |
提交时间 |
2017-06-29 09:07:53 |
内存使用 |
4.89 MiB |
显示代码纯文本
- #include<bits/stdc++.h>
- #define syy myson
- using namespace std;
- const int maxn=20;
- long long f[1<<maxn],n,temp,m,un[30],cnt[1<<maxn];
- long long lowbit(int x)
- {
- return x&-x;
- }
- int Main()
- {
- freopen("examone.in","r",stdin);freopen("examone.out","w",stdout);
- scanf("%lld%lld",&n,&m);
- for(int i=1;i<=m;i++)
- {
- int a,b;
- scanf("%d%d",&a,&b);
- un[a]|=1<<(n-b);
- }
- temp=(1<<n)-1;
- for(long long i=1;i<=temp;i++)
- {
- cnt[i]+=cnt[i>>1]+(i&1);
- }
- f[0]=1;
- for(long long i=1;i<=temp;i++)
- for(long long j=i;j;j-=lowbit(j))
- {
- long long k=lowbit(j);
- if(k&un[cnt[i]])continue;
- f[i]+=f[i-k];
- }
- printf("%lld",f[temp]);
- return 0;
- }
- int main(){;}
- int syy=Main();