답안 #1023252

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1023252 2024-07-14T14:17:23 Z 12345678 조교 (CEOI16_popeala) C++17
0 / 100
46 ms 4756 KB
#include <bits/stdc++.h>

using namespace std;

const int nx=55, tx=2e4+5;

int n, t, s, dp[nx][tx], qs[nx], lst[nx][tx];
string str;

int cost(int l, int r)
{
    int tmp=0;
    for (int i=1; i<=n; i++) if (lst[i][r]<l) tmp+=qs[r]-qs[l-1];
    return tmp;
}

void solve(int l, int r, int layer, int optl, int optr)
{
    if (r<l) return;
    int md=(l+r)/2;
    pair<int, int> mn={INT_MAX, 0};
    for (int i=optl; i<=min(md, optr); i++) mn=min(mn, {dp[layer-1][i-1]+cost(i, md), i});
    dp[layer][md]=mn.first;
    //if (layer==2&&md==3) cout<<"debug "<<mn.first<<' '<<mn.second<<'\n';
    solve(l, md-1, layer, optl, mn.second);
    solve(md+1, r, layer, mn.second, optr);
}

int main()
{
    cin.tie(NULL)->sync_with_stdio(false);
    cin>>n>>t>>s;
    for (int i=1; i<=t; i++) cin>>qs[i], qs[i]+=qs[i-1];
    for (int i=1; i<=n; i++)
    {
        cin>>str;
        for (int j=1; j<=t; j++)
        {
            if (str[j-1]=='0') lst[i][j]=j;
            else lst[i][j]=lst[i][j-1];
        }
    }
    for (int i=1; i<=n; i++) dp[1][i]=cost(1, i);
    for (int i=2; i<=s; i++) solve(i, t, i, i, t);
    //for (int i=1; i<=s; i++) for (int j=1; j<=t; j++) cout<<i<<' '<<j<<' '<<dp[i][j]<<'\n';
    for (int i=1; i<=s; i++) cout<<dp[i][t]<<'\n';
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Incorrect 1 ms 2652 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 9 ms 4756 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 46 ms 3408 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Incorrect 1 ms 2652 KB Output isn't correct
3 Halted 0 ms 0 KB -