# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
201195 | 2020-02-09T18:15:35 Z | SamAnd | Vještica (COCI16_vjestica) | C++17 | 129 ms | 1528 KB |
#include <bits/stdc++.h> using namespace std; const int N = 18, M = 1000006; int n; char s[M]; int a[N][26]; int b[(1 << N)]; int dp[(1 << N)]; int main() { scanf("%d", &n); for (int i = 0; i < n; ++i) { scanf(" %s", s); int m = strlen(s); for (int j = 0; j < m; ++j) a[i][s[j] - 'a']++; } for (int x = 0; x < (1 << n); ++x) { for (int j = 0; j < 26; ++j) { int minu = N; for (int i = 0; i < n; ++i) { if ((x & (1 << i))) { minu = min(minu, a[i][j]); } } b[x] += minu; } } for (int x = 1; x < (1 << n); ++x) { dp[x] = N; int q = 0; for (int i = 0; i < n; ++i) { if ((x & (1 << i))) { ++q; } } if (q == 1) { dp[x] = b[x]; continue; } for (int y = (x - 1) & x; y; y = (y - 1) & x) { int z = (x ^ y); dp[x] = min(dp[x], b[x] + dp[z] + dp[y] - b[x] - b[x]); } } printf("%d\n", dp[(1 << n) - 1] + 1); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 5 ms | 376 KB | Output isn't correct |
2 | Incorrect | 6 ms | 376 KB | Output isn't correct |
3 | Incorrect | 5 ms | 376 KB | Output isn't correct |
4 | Incorrect | 128 ms | 888 KB | Output isn't correct |
5 | Incorrect | 121 ms | 892 KB | Output isn't correct |
6 | Incorrect | 123 ms | 1144 KB | Output isn't correct |
7 | Incorrect | 129 ms | 1356 KB | Output isn't correct |
8 | Incorrect | 125 ms | 1272 KB | Output isn't correct |
9 | Incorrect | 126 ms | 1528 KB | Output isn't correct |
10 | Incorrect | 129 ms | 1304 KB | Output isn't correct |