# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
127958 | Plurm | Popeala (CEOI16_popeala) | C++11 | 2053 ms | 4740 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>
using namespace std;
char res[64][20005];
int dp[64][20005];
long long cmask[20005];
int qs[20005];
int pts[20005];
long long ST[15][32768];
void build(){
for(int j = 0; j < 32768; j++){
ST[0][j] = j < 20005 ? cmask[j] : 0ll;
}
for(int i = 1; i < 15; i++){
for(int j = 0; j + (1 << i) - 1 < 32768; j++){
ST[i][j] = ST[i-1][j] & ST[i-1][j+(1<<(i-1))];
}
}
}
int query(int l, int r){
int d = r-l+1;
int k = log2(d);
return __builtin_popcountll(ST[k][l] & ST[k][r-(1 << k)+1]);
}
int main(){
int n,t,s;
scanf("%d%d%d",&n,&t,&s);
for(int i = 1; i <= t; i++){
scanf("%d",pts+i);
qs[i] = qs[i-1] + pts[i];
}
for(int i = 0; i < n; i++){
scanf("%s",res[i]+1);
}
for(int i = 1; i <= t; i++){
long long mask = 0ll;
for(int j = 0; j < n; j++){
if(res[j][i] == '1') mask |= 1ll << j;
}
cmask[i] = mask;
}
build();
for(int i = 1; i <= s; i++){
dp[i][0] = 2e9;
for(int j = 1; j <= t; j++){
dp[i][j] = 2e9;
long long mask = cmask[j];
for(int k = j-1; k >= 0; k--){
if((i == 1 && k == 0) || i != 1) dp[i][j] = min(dp[i][j], dp[i-1][k] + query(k+1,j) * (qs[j] - qs[k]));
mask &= cmask[k];
}
}
printf("%d\n",dp[i][t]);
}
return 0;
}
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... |