// TLE: O(2^n m) #include #include std::vector calc_f(const size_t n, const size_t m, const size_t k, const std::vector &s) { std::vector f(1 << n); for (uint t = 0; t < 1u << n; ++t) for (size_t i = 0; i < m; ++i) { f[t] += __builtin_popcount(t & s[i]) >= k; } return f; } std::vector calc_g(const size_t n, const size_t m, const std::vector &f) { std::vector g(m + 1, n + 1); for (uint t = 0; t < 1u << n; ++t) { g[f[t]] = std::min(g[f[t]], __builtin_popcount(t)); } for (size_t p = m; p; --p) { g[p - 1] = std::min(g[p - 1], g[p]); } return g; } int main() { std::ios::sync_with_stdio(false); std::cin.tie(nullptr); size_t n, m, k; std::cin >> n >> m >> k; std::vector s(m); for (size_t i = 0; i < m; ++i) { std::string si; std::cin >> si; for (size_t j = 0; j < n; ++j) { s[i] |= (si[j] - '0') << j; } } auto f = calc_f(n, m, k, s); auto g = calc_g(n, m, f); for (size_t p = 1; p <= m; ++p) { std::cout << g[p] << '\n'; } }