답안 #483741

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
483741 2021-11-01T02:10:48 Z socpite 조교 (CEOI16_popeala) C++14
0 / 100
71 ms 2380 KB
#include<bits/stdc++.h>
using namespace std;

#define oo 1000000000000

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

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);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Incorrect 1 ms 332 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 15 ms 716 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 71 ms 2380 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Incorrect 1 ms 332 KB Output isn't correct