Submission #1032649

# Submission time Handle Problem Language Result Execution time Memory
1032649 2024-07-24T05:10:01 Z 김은성(#10965) Popeala (CEOI16_popeala) C++17
17 / 100
2000 ms 4816 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, pr);
    go(idx, mid+1, r, 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 'void go(int, int, int, int, int)':
popeala.cpp:17:24: warning: variable 'opt' set but not used [-Wunused-but-set-variable]
   17 |     int mid = (l+r)/2, opt, k, temp = 2147000000;
      |                        ^~~
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);
      |         ~~~~~^~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 243 ms 4712 KB Output is correct
2 Correct 199 ms 4728 KB Output is correct
3 Correct 256 ms 4696 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 2069 ms 4816 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 243 ms 4712 KB Output is correct
4 Correct 199 ms 4728 KB Output is correct
5 Correct 256 ms 4696 KB Output is correct
6 Execution timed out 2069 ms 4816 KB Time limit exceeded
7 Halted 0 ms 0 KB -