比赛 |
2025暑期集训第6场 |
评测结果 |
AWWWWWWWWWWWWWWWWWWWW |
题目名称 |
Moo Route |
最终得分 |
5 |
用户昵称 |
LikableP |
运行时间 |
0.202 s |
代码语言 |
C++ |
内存使用 |
1.62 MiB |
提交时间 |
2025-07-12 10:33:00 |
显示代码纯文本
#include <algorithm>
#include <cstdio>
#include <ctime>
template <typename T> T read();
template <typename T> void write(T, char);
const int MAXN = 1e5 + 10;
int n;
int a[MAXN];
int ans;
bool check() {
return ::std::all_of(a + 1, a + n + 1, [](int x) { return x == 0; });
}
void dfs(int now) {
if (clock() > 1900) {
return;
}
bool ok = false;
if (now < n && a[now]) {
ok = true;
a[now]--;
dfs(now + 1);
a[now]++;
}
if (now > 0 && a[now - 1]) {
ok = true;
a[now - 1]--;
dfs(now - 1);
a[now - 1]++;
}
if (!ok) (ans += check()) %= int(1e9 + 7);
}
int main() {
freopen("moorouteg.in", "r", stdin);
freopen("moorouteg.out", "w", stdout);
n = read<int>();
for (int i = 0; i < n; ++i) {
a[i] = read<int>();
}
dfs(0);
write(ans / 2, '\n');
return 0;
}
#define isdigit(ch) (ch >= '0' && ch <= '9')
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;
}
#undef isdigit
template <typename T> void write(T x, char ed) {
if (x < 0) x = -x, putchar('-');
int sta[sizeof(T) << 2], top = 0;
do {
sta[++top] = x % 10;
x /= 10;
} while (x);
while (top) {
putchar(sta[top--] ^ 48);
}
putchar(ed);
}