用户输出
0
Special Judge 信息
Files user_out and answer differ
系统信息
Exited with return code 0
编号 | 题目 | 状态 | 分数 | 总时间 | 内存 | 代码 / 答案文件 | 提交者 | 提交时间 |
---|---|---|---|---|---|---|---|---|
#2552 | #1040. 1-04G. nocriz的爆搜题 | Wrong Answer | 28 | 298 ms | 360 K | C++ 11 / 2.1 K | RBTsDefoliation | 2019-06-25 22:57:19 |
#include <bits/stdc++.h>
#define MAXN 10005
int n, m;
int a[MAXN];
long long ans = 0;
int f(int x) {
int ret = 1;
while (x >= 1) {
ret *= x;
--x;
}
return ret;
}
void swap(int x, int y, int len) {
for (int i = 0; i < len; ++i) std::swap(a[x + i], a[y + i]);
}
bool check(int start, int len) {
for (int i = start + 1; i < start + len; ++i)
if (a[i] != a[i - 1] + 1)
return false;
return true;
}
void dfs(int cur, int len, int step) {
if (cur == n + 1) {
ans += f(step);
return;
}
int cnt = 0;
int tmp[2];
for (int i = 0; i < m; i += len)
if (!check(i, len)) {
if (cnt == 2)
return;
tmp[cnt] = i;
++cnt;
}
if (cnt == 0)
dfs(cur + 1, len * 2, step);
else if (cnt == 1) {
swap(tmp[0], tmp[0] + len / 2, len / 2);
if (check(tmp[0], len))
dfs(cur + 1, len * 2, step + 1);
swap(tmp[0], tmp[0] + len / 2, len / 2);
} else {
swap(tmp[0], tmp[1], len / 2);
if (check(tmp[0], len) && check(tmp[1], len))
dfs(cur + 1, len * 2, step + 1);
swap(tmp[0], tmp[1], len / 2);
swap(tmp[0], tmp[1] + len / 2, len / 2);
if (check(tmp[0], len) && check(tmp[1], len))
dfs(cur + 1, len * 2, step + 1);
swap(tmp[0], tmp[1] + len / 2, len / 2);
swap(tmp[0] + len / 2, tmp[1], len / 2);
if (check(tmp[0], len) && check(tmp[1], len))
dfs(cur + 1, len * 2, step + 1);
swap(tmp[0] + len / 2, tmp[1], len / 2);
swap(tmp[0] + len / 2, tmp[1] + len / 2, len / 2);
if (check(tmp[0], len) && check(tmp[1], len))
dfs(cur + 1, len * 2, step + 1);
swap(tmp[0] + len / 2, tmp[1] + len / 2, len / 2);
}
}
int main() {
scanf("%d", &n);
m = pow(2, n);
for (int i = 0; i < m; ++i) scanf("%d", &a[i]);
dfs(1, 2, 0);
printf("%lld", ans);
return 0;
}
用户输出
0
Special Judge 信息
Files user_out and answer differ
系统信息
Exited with return code 0
用户输出
0
Special Judge 信息
Files user_out and answer differ
系统信息
Exited with return code 0
用户输出
0
Special Judge 信息
Files user_out and answer differ
系统信息
Exited with return code 0
用户输出
0
系统信息
Exited with return code 0
用户输出
0
Special Judge 信息
Files user_out and answer differ
系统信息
Exited with return code 0
用户输出
0
Special Judge 信息
Files user_out and answer differ
系统信息
Exited with return code 0
用户输出
0
Special Judge 信息
Files user_out and answer differ
系统信息
Exited with return code 0
用户输出
0
Special Judge 信息
Files user_out and answer differ
系统信息
Exited with return code 0
用户输出
0
Special Judge 信息
Files user_out and answer differ
系统信息
Exited with return code 0
用户输出
0
系统信息
Exited with return code 0
用户输出
0
Special Judge 信息
Files user_out and answer differ
系统信息
Exited with return code 0
用户输出
0
Special Judge 信息
Files user_out and answer differ
系统信息
Exited with return code 0
用户输出
0
Special Judge 信息
Files user_out and answer differ
系统信息
Exited with return code 0
用户输出
0
Special Judge 信息
Files user_out and answer differ
系统信息
Exited with return code 0
用户输出
0
Special Judge 信息
Files user_out and answer differ
系统信息
Exited with return code 0
用户输出
0
Special Judge 信息
Files user_out and answer differ
系统信息
Exited with return code 0
用户输出
1
Special Judge 信息
Files user_out and answer differ
系统信息
Exited with return code 0
用户输出
0
Special Judge 信息
Files user_out and answer differ
系统信息
Exited with return code 0
用户输出
0
Special Judge 信息
Files user_out and answer differ
系统信息
Exited with return code 0
用户输出
0
Special Judge 信息
Files user_out and answer differ
系统信息
Exited with return code 0
用户输出
0
系统信息
Exited with return code 0
用户输出
0
Special Judge 信息
Files user_out and answer differ
系统信息
Exited with return code 0
用户输出
0
系统信息
Exited with return code 0
用户输出
0
系统信息
Exited with return code 0
用户输出
0
Special Judge 信息
Files user_out and answer differ
系统信息
Exited with return code 0
用户输出
0
系统信息
Exited with return code 0
用户输出
0
系统信息
Exited with return code 0
用户输出
0
系统信息
Exited with return code 0
用户输出
0
Special Judge 信息
Files user_out and answer differ
系统信息
Exited with return code 0
用户输出
0
系统信息
Exited with return code 0
用户输出
0
系统信息
Exited with return code 0
用户输出
0
系统信息
Exited with return code 0
用户输出
0
系统信息
Exited with return code 0
用户输出
0
Special Judge 信息
Files user_out and answer differ
系统信息
Exited with return code 0
用户输出
0
Special Judge 信息
Files user_out and answer differ
系统信息
Exited with return code 0
用户输出
0
Special Judge 信息
Files user_out and answer differ
系统信息
Exited with return code 0
用户输出
0
Special Judge 信息
Files user_out and answer differ
系统信息
Exited with return code 0
用户输出
0
Special Judge 信息
Files user_out and answer differ
系统信息
Exited with return code 0
用户输出
0
系统信息
Exited with return code 0
用户输出
0
系统信息
Exited with return code 0
用户输出
0
Special Judge 信息
Files user_out and answer differ
系统信息
Exited with return code 0
用户输出
0
Special Judge 信息
Files user_out and answer differ
系统信息
Exited with return code 0
用户输出
0
Special Judge 信息
Files user_out and answer differ
系统信息
Exited with return code 0
用户输出
0
Special Judge 信息
Files user_out and answer differ
系统信息
Exited with return code 0
用户输出
0
Special Judge 信息
Files user_out and answer differ
系统信息
Exited with return code 0
用户输出
0
Special Judge 信息
Files user_out and answer differ
系统信息
Exited with return code 0
用户输出
0
Special Judge 信息
Files user_out and answer differ
系统信息
Exited with return code 0
用户输出
0
Special Judge 信息
Files user_out and answer differ
系统信息
Exited with return code 0
用户输出
0
Special Judge 信息
Files user_out and answer differ
系统信息
Exited with return code 0
用户输出
0
Special Judge 信息
Files user_out and answer differ
系统信息
Exited with return code 0
用户输出
0
Special Judge 信息
Files user_out and answer differ
系统信息
Exited with return code 0
用户输出
0
Special Judge 信息
Files user_out and answer differ
系统信息
Exited with return code 0
用户输出
0
Special Judge 信息
Files user_out and answer differ
系统信息
Exited with return code 0
用户输出
0
Special Judge 信息
Files user_out and answer differ
系统信息
Exited with return code 0
用户输出
0
Special Judge 信息
Files user_out and answer differ
系统信息
Exited with return code 0
用户输出
0
Special Judge 信息
Files user_out and answer differ
系统信息
Exited with return code 0
用户输出
0
Special Judge 信息
Files user_out and answer differ
系统信息
Exited with return code 0
用户输出
0
Special Judge 信息
Files user_out and answer differ
系统信息
Exited with return code 0
用户输出
0
系统信息
Exited with return code 0
用户输出
0
Special Judge 信息
Files user_out and answer differ
系统信息
Exited with return code 0
用户输出
0
Special Judge 信息
Files user_out and answer differ
系统信息
Exited with return code 0
用户输出
0
系统信息
Exited with return code 0
用户输出
0
Special Judge 信息
Files user_out and answer differ
系统信息
Exited with return code 0
用户输出
0
Special Judge 信息
Files user_out and answer differ
系统信息
Exited with return code 0