Submission #483746

#TimeUsernameProblemLanguageResultExecution timeMemory
483746socpitePopeala (CEOI16_popeala)C++14
0 / 100
70 ms2252 KiB
#include<bits/stdc++.h> using namespace std; #define oo 100000000000000000 long long n, t, s; vector<string> board; long long pfxsum[20001][51]; long long pfxpoints[20001]; long long dp[20001][51]; long long ck(int l, int r){ long long re = 0; for(int i = 1; i <= n; i++){ if(pfxsum[r][i]-pfxsum[l-1][i] == r-l+1)re+=pfxpoints[r]-pfxpoints[l-1]; } return re; } void solve(int l, int r, int pl, int pr, int floor){ if(l > r)return; int mid = (l+r)/2; long long best = oo, pos; for(int i = pl; i <= min(pr, mid); i++){ if(dp[i-1][floor-1]+ck(i, mid) < best){ best = dp[i-1][floor-1]+ck(i, mid); pos = i; } } dp[mid][floor]=best; solve(l, mid-1, pl, pos, floor); solve(mid+1, r, pos, pr, floor); } int main(){ cin >> n >> t >> s; board.resize(n+1); pfxpoints[0]=0; for(int i = 1; i <= t; i++){ cin >> pfxpoints[i]; pfxpoints[i]+=pfxpoints[i-1]; } for(int i = 1; i <= n; i++){ cin>> board[i]; pfxsum[0][i]=0; for(int j = 1; j <= t; j++){ pfxsum[j][i]=pfxsum[j-1][i]; if(board[i][j-1]=='1')pfxsum[j][i]++; } } for(int i = 1; i <= t; i++){ dp[i][1]=0; dp[i][1]+=ck(1, i); } cout << dp[t][1] << endl; for(int i = 2; i <= s; i++){ solve(i, t, i, t, i); cout << dp[t][i] << endl; } }

Compilation message (stderr)

popeala.cpp: In function 'void solve(int, int, int, int, int)':
popeala.cpp:31:10: warning: 'pos' may be used uninitialized in this function [-Wmaybe-uninitialized]
   31 |     solve(l, mid-1, pl, pos, floor);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...