# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
127958 | Plurm | Popeala (CEOI16_popeala) | C++11 | 2053 ms | 4740 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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;
}
컴파일 시 표준 에러 (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... |