Submission #874916

# Submission time Handle Problem Language Result Execution time Memory
874916 2023-11-18T05:40:04 Z Sir_Ahmed_Imran Popeala (CEOI16_popeala) C++17
17 / 100
2000 ms 8540 KB
                            ///~~~LOTA~~~///
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define append push_back
#define add insert
#define nl '\n'
#define ff first
#define ss second
#define pii pair<int,int>
#define pic pair<int,char>
#define all(x) (x).begin(),(x).end()
#define sum(a) accumulate(all(a),0)
#define L0TA ios_base::sync_with_stdio(false);cin.tie(NULL)
#define terminator main
#define N 20001
int pnt[N];
string a[51];
int dp[51][N];
int pre[51][N];
void solve(){
    int n,m,o,p,q,r;
    cin>>n>>m>>o;
    for(int i=1;i<=m;i++){
        cin>>pnt[i];
        pnt[i]+=pnt[i-1];
    }
    for(int i=1;i<=n;i++)
        cin>>a[i];
    for(int i=0;i<51;i++)
        for(int j=0;j<N;j++)
            pre[i][j]=dp[i][j]=0;
    for(int i=1;i<=n;i++)
        for(int j=0;j<m;j++)
            pre[i][j+1]=pre[i][j]+a[i][j]-'0';
    for(int i=1;i<=m;i++)
        for(int j=1;j<=n;j++)
            dp[1][i]+=(pre[j][i]==i)*pnt[i];
    for(int i=2;i<=o;i++){
        for(int j=i;j<=m;j++){
            dp[i][j]=2e9;
            for(int k=i-1;k<j;k++){
                r=dp[i-1][k];
                for(int l=1;l<=n;l++)
                    r+=(pre[l][j]-pre[l][k]==j-k)*(pnt[j]-pnt[k]);
                dp[i][j]=min(dp[i][j],r);
            }
        }
    }
    for(int i=1;i<=o;i++)
        cout<<dp[i][m]<<nl;
}
int terminator(){
    L0TA;
    solve();
    return 0;
}

Compilation message

popeala.cpp: In function 'void solve()':
popeala.cpp:23:15: warning: unused variable 'p' [-Wunused-variable]
   23 |     int n,m,o,p,q,r;
      |               ^
popeala.cpp:23:17: warning: unused variable 'q' [-Wunused-variable]
   23 |     int n,m,o,p,q,r;
      |                 ^
# Verdict Execution time Memory Grader output
1 Correct 2 ms 8284 KB Output is correct
2 Correct 4 ms 8540 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 297 ms 8448 KB Output is correct
2 Correct 276 ms 8444 KB Output is correct
3 Correct 299 ms 8460 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 2059 ms 8540 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 8284 KB Output is correct
2 Correct 4 ms 8540 KB Output is correct
3 Correct 297 ms 8448 KB Output is correct
4 Correct 276 ms 8444 KB Output is correct
5 Correct 299 ms 8460 KB Output is correct
6 Execution timed out 2059 ms 8540 KB Time limit exceeded
7 Halted 0 ms 0 KB -