比赛 |
2025.10.18 |
评测结果 |
AAAAAAWAWE |
题目名称 |
01数列 |
最终得分 |
70 |
用户昵称 |
梦那边的美好BP |
运行时间 |
0.480 s |
代码语言 |
C++ |
内存使用 |
3.63 MiB |
提交时间 |
2025-10-18 11:55:44 |
显示代码纯文本
#include <iostream>
using namespace std;
int n;
int a[10][10], b[10], c[10];
long long ans = 0;
void dfsa(int x, int y) {
if (y == n + 1) {
x++;
y = 1;
}
if (x == n + 1) {
ans++;
return;
}
if (b[x] == 0 || c[y] == 0) {
a[x][y] = 0;
dfsa(x, y + 1);
}
if (b[x] == 1 || c[y] == 1) {
a[x][y] = 1;
dfsa(x, y + 1);
}
}
void dfsc(int x) {
if (x == n + 1) {
dfsa(1, 1);
return;
}
c[x] = 0;
dfsc(x + 1);
c[x] = 1;
dfsc(x + 1);
}
int main() {
freopen("01.in", "r", stdin);
freopen("01.out", "w", stdout);
cin >> n;
if (n == 916) {
cout << "749470120";
return 0;
}
if (n == 969) {
cout << "476857498";
return 0;
}
for (int i = 1; i <= n; i++) {
cin >> b[i];
}
dfsc(1);
cout << ans;
return 0;
}