Submission #619403

# Submission time Handle Problem Language Result Execution time Memory
619403 2022-08-02T11:42:57 Z drdilyor Popeala (CEOI16_popeala) C++17
26 / 100
2000 ms 6228 KB
#include <bits/stdc++.h>
#ifdef ONPC
    #include "t_debug.cpp"
#else
    #define debug(...) 42
#endif
#define sz(a) ((int)(a).size())
using namespace std;
using ll = long long;
const int INF = 2e9+1;
const ll INFL = 1e18;
const int RANDOM = chrono::high_resolution_clock::now().time_since_epoch().count();
mt19937 rng(RANDOM);
template<typename T, typename U> istream& operator>>(istream& is, pair<T, U>& p) { return is >> p.first >> p.second; }
const int N = 2e4, LOGN = 17, K = 64, MOD = 1e9+7;

int solve() {
    int n, t, s;
    cin >> n >> t >> s;
    if (!cin) return 1;

    vector<int> pts(t);
    for (auto& i : pts) {cin >> i;}
    vector<string> table(n);
    for (auto& i : table) {cin >> i;}
    vector<bitset<K>> res(t);
    for (int tc = 0; tc < t; tc++) {
        for (int c = 0; c < n; c++) {
            res[tc][c] = table[c][tc] == '0';
        }
    }

    int dp[N+1][K+1];
    dp[t][0] = 0;
    for (int i = 0; i < t; i++)
        dp[i][0] = INF;
    for (int g = 1; g <= s; g++)
        dp[t][g] = INF;

    for (int i = t-1; i >= 0; i--) {
        for (int g = 1; g <= s; g++) {
            int score = 0;
            bitset<K> solved;
            dp[i][g] = INF;
            for (int j = i; j < t; j++) {
                score += pts[j];
                solved |= res[j];
                int count = n -solved.count();
                dp[i][g] = min(dp[i][g], score * count + dp[j+1][g-1]);
            }
        }
    }

    for (int k = 1; k <= s; k++) {
        cout << dp[0][k] << '\n';
    }
    
    return 0;
}

signed main() {
    cin.tie(0)->sync_with_stdio(0);
    int t = 1;
    #ifdef ONPC
    t = 10000;
    #endif
    while (t-- && cin) {
        if (solve()) break;
        #ifdef ONPC
            cout << "____________________" << endl;
        #endif
    }
    return 0;
}

/*
     █████               █████  ███  ████                               
    ▒▒███               ▒▒███  ▒▒▒  ▒▒███                               
  ███████  ████████   ███████  ████  ▒███  █████ ████  ██████  ████████ 
 ███▒▒███ ▒▒███▒▒███ ███▒▒███ ▒▒███  ▒███ ▒▒███ ▒███  ███▒▒███▒▒███▒▒███
▒███ ▒███  ▒███ ▒▒▒ ▒███ ▒███  ▒███  ▒███  ▒███ ▒███ ▒███ ▒███ ▒███ ▒▒▒ 
▒███ ▒███  ▒███     ▒███ ▒███  ▒███  ▒███  ▒███ ▒███ ▒███ ▒███ ▒███     
▒▒████████ █████    ▒▒████████ █████ █████ ▒▒███████ ▒▒██████  █████    
 ▒▒▒▒▒▒▒▒ ▒▒▒▒▒      ▒▒▒▒▒▒▒▒ ▒▒▒▒▒ ▒▒▒▒▒   ▒▒▒▒▒███  ▒▒▒▒▒▒  ▒▒▒▒▒     
                                            ███ ▒███                    
                                           ▒▒██████                     
                                            ▒▒▒▒▒▒
*/
# Verdict Execution time Memory Grader output
1 Correct 2 ms 5332 KB Output is correct
2 Correct 2 ms 5332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 30 ms 5416 KB Output is correct
2 Correct 27 ms 5444 KB Output is correct
3 Correct 26 ms 5440 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 511 ms 5528 KB Output is correct
2 Correct 886 ms 5600 KB Output is correct
3 Correct 1540 ms 5968 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 5332 KB Output is correct
2 Correct 2 ms 5332 KB Output is correct
3 Correct 30 ms 5416 KB Output is correct
4 Correct 27 ms 5444 KB Output is correct
5 Correct 26 ms 5440 KB Output is correct
6 Correct 511 ms 5528 KB Output is correct
7 Correct 886 ms 5600 KB Output is correct
8 Correct 1540 ms 5968 KB Output is correct
9 Execution timed out 2066 ms 6228 KB Time limit exceeded
10 Halted 0 ms 0 KB -