Submission #127958

#TimeUsernameProblemLanguageResultExecution timeMemory
127958PlurmPopeala (CEOI16_popeala)C++11
17 / 100
2053 ms4740 KiB
#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)

popeala.cpp: In function 'int main()':
popeala.cpp:26:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d%d",&n,&t,&s);
     ~~~~~^~~~~~~~~~~~~~~~~~~
popeala.cpp:28:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d",pts+i);
         ~~~~~^~~~~~~~~~~~
popeala.cpp:32:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%s",res[i]+1);
         ~~~~~^~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...