# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
168370 | 2019-12-12T19:41:51 Z | rzbt | Vještica (COCI16_vjestica) | C++14 | 114 ms | 800 KB |
#include <bits/stdc++.h> #define mp make_pair #define pb push_back #define F first #define S second #define all(x) x.begin(),x.end() #define MAXN 17 typedef long long ll; using namespace std; int n; char s[1000006]; int svi[MAXN][28]; int dp[(1<<MAXN)+5]; vector<int> tren; int main() { scanf("%d", &n); for(int i=0;i<n;i++){ scanf("%s",s); int len=strlen(s); for(int j=0;j<len;j++) svi[i][s[j]-'a']++; dp[1<<i]=len; } for(int i=1;i<(1<<n);i++){ if(__builtin_popcount(i)==1)continue; dp[i]=INT_MAX; tren.clear(); int zajed=0,kolko=0; for(int j=0;j<n;j++){ if((1<<j)&i)tren.pb(j); } kolko=(1<<tren.size())-1; for(int j=0;j<26;j++){ int kek=22; for(auto x:tren)kek=min(kek,svi[x][j]); zajed+=kek; } for(int j = (i - 1) & i; j > 0; j = (j - 1) & i){ //printf(" %d %d %d %d\n",prvi,drugi,j,i); dp[i]=min(dp[i],dp[j]+dp[i^j]-zajed); } } printf("%d",1+dp[(1<<n)-1]); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 256 KB | Output is correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
4 | Incorrect | 107 ms | 632 KB | Output isn't correct |
5 | Incorrect | 108 ms | 772 KB | Output isn't correct |
6 | Incorrect | 114 ms | 604 KB | Output isn't correct |
7 | Incorrect | 110 ms | 800 KB | Output isn't correct |
8 | Incorrect | 110 ms | 704 KB | Output isn't correct |
9 | Incorrect | 110 ms | 632 KB | Output isn't correct |
10 | Incorrect | 110 ms | 760 KB | Output isn't correct |