답안 #1023275

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1023275 2024-07-14T14:43:25 Z 12345678 조교 (CEOI16_popeala) C++17
0 / 100
30 ms 1624 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, mn.second, optr);
    solve(md+1, r, layer, optl, mn.second);
}

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<=t; 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 348 KB Output is correct
2 Incorrect 1 ms 604 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 860 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 30 ms 1624 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Incorrect 1 ms 604 KB Output isn't correct
3 Halted 0 ms 0 KB -