// WA: greedy (1) #include #include #include 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; } } std::vector> hist(n); for (size_t i = 0; i < n; ++i) { hist[i] = { 0, i }; } for (uint e : s) { for (size_t i = 0; i < n; ++i) if ((e >> i) & 1) ++hist[i].first; } std::sort(hist.begin(), hist.end(), std::greater<>()); std::vector g(m + 1, n + 1); size_t ok = 0; uint t = 0, ct = 0; while (ok < m) { t |= 1 << hist[ct].second; ++ct; ok = 0; for (uint e : s) ok += __builtin_popcount(t & e) >= k; g[ok] = ct; } for (size_t p = m; p; --p) { g[p - 1] = std::min(g[p - 1], g[p]); } for (size_t p = 1; p <= m; ++p) { std::cout << g[p] << '\n'; } }