Submission #155882

# Submission time Handle Problem Language Result Execution time Memory
155882 2019-10-01T14:45:43 Z Ruxandra985 Popeala (CEOI16_popeala) C++14
0 / 100
3 ms 504 KB
/// imi place sa scriu semi bruturi aparent
#include <cstdio>
#include <iostream>
using namespace std;
int dp[51][20001];
long long ok[20010];
int val[20010];
int biti1 (long long x){
    int sol = 0;
    while (x){
        sol = sol + (x&1);
        x/=2;
    }
    return sol;
}
int main()
{
    FILE *fin = fopen ("a.in" , "r");
    FILE *fout = fopen ("a.out" , "w");
    int n,t,s,i,j,k;
    long long sum;
    fscanf (fin,"%d%d%d",&n,&t,&s);
    for (i=1;i<=t;i++){
        fscanf (fin,"%d",&val[i]);
        val[i]+=val[i-1];
    }
    for (i=1;i<=n;i++){
        fgetc(fin);
        for (j=1;j<=t;j++)
            ok[j]=(long long)(fgetc(fin)-'0') * ((long long)1<<(i-1)) + ok[j];
    }

    for (j=1;j<=s;j++){
        for (i=j;i<=t;i++){
            sum = ok[i];
            dp[j][i] = 2000000000;
            for (k=i;k;k--){
                sum = (sum & ok[k]);
                if (j-1<=k-1)
                    dp[j][i] = min (dp[j][i] , dp[j-1][k-1] + (val[i] - val[k-1]) * biti1(sum));
            }
        }
    }

    for (j=1;j<=s;j++)
        fprintf (fout,"%d\n",dp[j][t]);
    return 0;
}

Compilation message

popeala.cpp: In function 'int main()':
popeala.cpp:22:12: warning: ignoring return value of 'int fscanf(FILE*, const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     fscanf (fin,"%d%d%d",&n,&t,&s);
     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
popeala.cpp:24:16: warning: ignoring return value of 'int fscanf(FILE*, const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         fscanf (fin,"%d",&val[i]);
         ~~~~~~~^~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 376 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 376 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 376 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -