记录编号 |
240899 |
评测结果 |
AAAAAAAAAA |
题目名称 |
雕塑安置 |
最终得分 |
100 |
用户昵称 |
Fmuckss |
是否通过 |
通过 |
代码语言 |
C++ |
运行时间 |
0.745 s |
提交时间 |
2016-03-24 08:08:33 |
内存使用 |
171.15 MiB |
显示代码纯文本
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
long long f[21][1<<20];
int cant[21];
int settle[21];
int top;
int n, m;
long long ans;
inline void make_settle() {
for(int i = 1; i <= n; i++) {
settle[i] = 1<<(i-1);
top += settle[i];
}
}
inline void read() {
scanf("%d %d", &n, &m);
int x, y;
for(int i = 1; i <= m; i++) {
scanf("%d %d", &x, &y);
cant[x] += 1<<(y-1);
}
}
inline void solve() {
f[0][0] = 1;
for(int i = 1; i <= n; i++) {
for(int j = 0; j <= top; j++) {
if(!f[i-1][j]) continue;
for(int k = 1; k <= n; k++) {
if((j & settle[k]) | (cant[i] & settle[k])) continue;
f[i][j | settle[k]] += f[i-1][j];
}
}
}
for(int i = 0; i <= top; i++) {
ans += f[n][i];
}
printf("%lld", ans);
}
int main() {
freopen("arrange.in", "r", stdin);
freopen("arrange.out", "w", stdout);
read();
make_settle();
// if(n <= 5) {
// dfs(1, 0);
// printf("%lld\n", ans);
// return 0;
// }
solve();
return 0;
}