# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
500619 | rainboy | Tortoise (CEOI21_tortoise) | C11 | 403 ms | 332900 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <stdio.h>
#include <string.h>
#define N 20
#define INF 0x3f3f3f3f
int min(int a, int b) { return a < b ? a : b; }
int main() {
static int aa[N], dp[1 << N][N][2], dq[1 << N][N][2];
int n, i, b, t, s, s_, ans;
scanf("%d", &n);
for (i = 0; i < n; i++)
scanf("%d", &aa[i]);
for (b = 0; b < 1 << n; b++)
for (i = 0; i < n; i++)
dp[b][i][0] = dp[b][i][1] = INF;
dp[0][0][0] = 0;
for (t = 0; t <= (n - 1) * 2; t++) {
s = 1 << (t + 1) / 2, s_ = 1 << (t + 2) / 2;
for (b = 0; b < 1 << n; b += s)
for (i = 0; i < n; i++)
dq[b][i][0] = dq[b][i][1] = INF;
for (b = 0; b < 1 << n; b += s)
for (i = 0; i < n; i++) {
if ((b & 1 << i) == 0 && aa[i] == 1)
dp[b | 1 << i][i][1] = min(dp[b | 1 << i][i][1], dp[b][i][0]);
if (aa[i] == -1)
dp[b][i][0] = min(dp[b][i][0], dp[b][i][1]);
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |