Submission #924133

# Submission time Handle Problem Language Result Execution time Memory
924133 2024-02-08T13:55:06 Z JakobZorz Popeala (CEOI16_popeala) C++17
0 / 100
2000 ms 11100 KB
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<algorithm>
#include<limits.h>
#include<math.h>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<iomanip>
#include<cstring>
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using namespace std;
 
int n,t,s;
int pts[20000];
int prev_done[50][20000];
ll done[20000];
ll dp[51][20001];
 
void solve(){
    cin>>n>>t>>s;
    for(int i=0;i<t;i++)
        cin>>pts[i];
    for(int i=0;i<n;i++){
        string str;
        cin>>str;
        for(int j=0;j<t;j++){
            if(str[j]=='1'){
                done[j]+=1LL<<i;
                if(j)
                    prev_done[i][j]=prev_done[i][j-1];
                else
                    prev_done[i][j]=-1;
            }else{
                prev_done[i][j]=i;
            }
        }
    }
    
    for(int i=0;i<51;i++)
        for(int j=0;j<20001;j++)
            dp[i][j]=1e18;
    
    dp[0][0]=0;
    
    for(int num=1;num<=s;num++){
        for(int i=0;i<=t;i++){
            vector<int>to_check;
            //for(int j=i-1;j>=0;j--)
                //to_check.push_back(j);
            
            for(int j=i-1;j>=0&&j>=i-10;j--)
                to_check.push_back(j);
            for(int j=num-1;j<i-1&&j<num+10;j++)
            
            //to_check.push_back(i-1);
            //to_check.push_back(num-1);
            for(int p=0;p<n;p++){
                int a=prev_done[p][i];
                if(num-1<a&&a<i-1)
                    to_check.push_back(a);
            }
            
            for(int idx:to_check){
                ll ppl=(1LL<<n)-1;
                ll csum=0;
                for(int j=i-1;j>=idx;j--){
                    csum+=pts[j];
                    ppl&=done[j];
                }
                int ppl_active=__builtin_popcountll(ppl);
                dp[num][i]=min(dp[num][i],dp[num-1][idx]+csum*ppl_active);
            }
        }
    }
    
    for(int i=0;i<s;i++)
        cout<<dp[i+1][t]<<"\n";
}
 
int main(){
    ios::sync_with_stdio(false);cout.tie(NULL);cin.tie(NULL);
    //freopen("input.in","r",stdin);freopen("output.out","w",stdout);
    int t=1;//cin>>t;
    while(t--)solve();
    return 0;
}
 
/*
 
2 3 3
4 3 5
101
110
 
 
0
8
16
 
 */
# Verdict Execution time Memory Grader output
1 Correct 2 ms 8796 KB Output is correct
2 Incorrect 3 ms 10844 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 780 ms 11012 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2047 ms 11100 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 8796 KB Output is correct
2 Incorrect 3 ms 10844 KB Output isn't correct
3 Halted 0 ms 0 KB -