比赛 |
2025.10.18 |
评测结果 |
AAAATTTTTT |
题目名称 |
01数列 |
最终得分 |
40 |
用户昵称 |
LikableP |
运行时间 |
12.027 s |
代码语言 |
C++ |
内存使用 |
20.65 MiB |
提交时间 |
2025-10-18 09:06:31 |
显示代码纯文本
#include <cstdio>
#include <cctype>
template <typename T> T read() {
T res = 0, f = 1;
char ch = getchar();
for (; !isdigit(ch); ch = getchar()) if (ch == '-') f = -1;
for (; isdigit(ch); ch = getchar()) res = (res << 3) + (res << 1) + (ch ^ 48);
return res * f;
}
template <typename T> void read(T& x) {
x = read<T>();
}
template <typename T, typename ...Others> void read(T& x, Others& ...y) {
read(x);
read(y...);
}
void read(char* x) {
char ch = getchar();
for (; isspace(ch); ch = getchar());
for (; !isspace(ch); ch = getchar()) *x++ = ch;
*x = 0;
}
void write(__int128 x) {
if (x < 0) x = -x, putchar('-');
int sta[64], top = 0;
do {
sta[++top] = x % 10;
x /= 10;
} while (x);
while (top) {
putchar(sta[top--] ^ 48);
}
}
template <typename T> void write(T x) {
write((__int128)x);
}
void write(char x) {
putchar(x);
}
void write(char* x) {
while (*x) putchar(*x++);
}
void write(const char* x) {
while (*x) putchar(*x++);
}
template <typename T, typename ...Others> void write(T x, Others ...y) {
write(x);
write(y...);
}
const int MAXN = 1010;
int n;
int a[MAXN][MAXN], b[MAXN], c[MAXN];
int ans;
void check() {
for (int i = 1; i <= n; ++i) {
for (int j = 1; j <= n ; ++j) {
if (a[i][j] != b[i] && a[i][j] != c[j]) return ;
}
}
ans++;
if (ans == 1000000007) ans = 0;
}
void generate_a(int nowx, int nowy) {
if (nowy > n) {
nowx++;
nowy = 1;
}
if (nowx > n) {
check();
return ;
}
a[nowx][nowy] = 1;
generate_a(nowx, nowy + 1);
a[nowx][nowy] = 0;
generate_a(nowx, nowy + 1);
}
void generate_c(int now) {
if (now > n) {
generate_a(1, 1);
return ;
}
c[now] = 1;
generate_c(now + 1);
c[now] = 0;
generate_c(now + 1);
}
int main() {
freopen("01.in", "r", stdin);
freopen("01.out", "w", stdout);
read(n);
for (int i = 1; i <= n ; ++i) {
read(b[i]);
}
generate_c(1);
write(ans, '\n');
return 0;
}