Submission #1032651

# Submission time Handle Problem Language Result Execution time Memory
1032651 2024-07-24T05:14:37 Z 김은성(#10965) Popeala (CEOI16_popeala) C++17
8 / 100
271 ms 6740 KB
#include <bits/stdc++.h>
using namespace std;
int p[20009], dp[52][20009];
int n, r[52][20009];
char res[20009];
int solved(int s, int e){
    int ans = 0, i;
    for(i=1; i<=n; i++){
        if(r[i][e] - r[i][s-1] == e-s+1)
            ans++;
    }
    return ans;
}
void go(int idx, int l, int r, int pl, int pr){
    if(l>r)
        return;
    int mid = (l+r)/2, opt, k, temp = 2147000000;
    for(k=pl; k<=pr && k<mid; k++){
        int x = dp[idx-1][k] + solved(k+1, mid) * (p[mid] - p[k]);
        if(x < temp){
            temp = x;
            opt = k;
        }
    }
    dp[idx][mid] = temp;
    go(idx, l, mid-1, pl, min(opt+40, pr));
    go(idx, mid+1, r, max(opt-40, pl), pr);
}
int main(){
    int t, s, i, j;
    scanf("%d %d %d", &n, &t, &s);
    for(i=1; i<=t; i++){
        scanf("%d", &p[i]);
        p[i] += p[i-1];
    }
    for(i=1; i<=n; i++){
        scanf(" %s", res+1);
        for(j=1; j<=t; j++)
            r[i][j] = r[i][j-1] + res[j] - '0';
    }
    for(i=1; i<=t; i++)
        dp[1][i] = solved(1, i) * p[i];
    for(i=2; i<=s; i++){
        go(i, i, t, i-1, t-1);
    }
    for(i=1;i <=s; i++)
        printf("%d\n", dp[i][t]);
    return 0;
}

Compilation message

popeala.cpp: In function 'int main()':
popeala.cpp:31:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   31 |     scanf("%d %d %d", &n, &t, &s);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
popeala.cpp:33:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   33 |         scanf("%d", &p[i]);
      |         ~~~~~^~~~~~~~~~~~~
popeala.cpp:37:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   37 |         scanf(" %s", res+1);
      |         ~~~~~^~~~~~~~~~~~~~
popeala.cpp: In function 'void go(int, int, int, int, int)':
popeala.cpp:26:34: warning: 'opt' may be used uninitialized in this function [-Wmaybe-uninitialized]
   26 |     go(idx, l, mid-1, pl, min(opt+40, pr));
      |                               ~~~^~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4440 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 40 ms 4700 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 271 ms 6740 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4440 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Incorrect 40 ms 4700 KB Output isn't correct
4 Halted 0 ms 0 KB -