# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
47687 | tieunhi | Vještica (COCI16_vjestica) | C++14 | 369 ms | 3140 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 <bits/stdc++.h>
#define N 16
using namespace std;
int n, a[N][26], sz[N];
int dp[(1 << N)];
int solve(int mask)
{
if (dp[mask] != -1)
return dp[mask];
if (mask == 0)
return (dp[mask] = 0);
if (__builtin_popcount(mask) == 1)
{
for (int i = 0; i < n; i++)
if ((mask >> i) & 1)
return (dp[mask] = sz[i]);
}
int common = 0;
for (int j = 0; j < 26; j++)
{
int x = 1e9;
for (int i = 0; i < n; i++)
if ((mask >> i) & 1)
x = min(x, a[i][j]);
common += x;
}
dp[mask] = 1e9;
for (int i = (mask-1)&mask; i; i = (i-1)&mask)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |