1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106
| #include <bits/stdc++.h> #define arrout(a, l, r) rep(i, l, r) cout << a[i] << " \n"[i == r] #define arrin(a, l, r) rep(i, l, r) cin >> a[i] #define rep(i, l, r) for(int i = l; i <= r; i ++) #define dep(i, l, r) for(int i = r; i >= l; i --) #define erg(i, x, n) for(int i = h[x]; ~i; i = ne[i]) #define deb(x) cout << #x << " = " << x << '\n' #define mem(a, x) memset(a, x, sizeof a) #define all(f) f.begin(), f.end() #define rall(f) f.rbegin(), f.rend() #define all1(f) f.begin() + 1, f.end() #define pii pair<int, int> #define m_p make_pair #define u_b upper_bound #define l_b lower_bound #define p_b push_back #define e_b emplace_back #define ldb long double #define db double #define int long long #define itn int #define il inline #define here system("pause") #define INF 0x3f3f3f3f3f3f3f3f #define inf 0x3f3f3f3f #define MOD 998244353 #define mod 1000000007 #define endl "\n" #define x first #define y second
#ifdef LOCAL #include "algo/debug.h" #else #define dbg(...) "cyh2.2" #define debug(...) "cyh2.2" #endif
using namespace std;
template <class T> inline void read(T& x) {x = 0;char c = getchar();bool f = 0;for(; !isdigit(c); c = getchar()) f ^= (c == '-'); for (; isdigit(c); c = getchar()) x = (x << 3) + (x << 1) + (c ^ 48); x = f ? -x : x; } template <class T> inline void write(T x) {if(x < 0) putchar('-'), x = -x;if(x < 10) putchar(x + 48);else write(x / 10), putchar(x % 10 + 48); }
inline int qmi(int a, int b, int p) {int ans = 1 % p;while(b){if(b & 1) ans = ans * a % p;a = a * a % p;b >>= 1;} return ans;} inline int inv(int a, int p) {return qmi(a, p - 2, p) % p;}
const int N = 2e5 + 10, M = 150, maxn = 20; const double pi = acos(-1); const long double E = exp(1); const double eps = 1e-8;
inline void solve() { int n, m, k; string s; bool ok = true; cin >> n >> m >> k >> s; for(int i = 0; i < n; i ++) { int l, r, ss, t, ans; l = i - 1, r = i + 1; ss = ans = 0, t = m; if(s[i] == '1') { ss ++; } else { ss ++, t --; } while(ss < k) { if(l >= 0&&ss < k) { if(s[l] == '0') { if(t > 0) { t --, ss ++, ans += i - l, l --; } else { l --; } } else { ss ++, ans += i - l, l --; } } if(r < n&&ss < k) { if(s[r] == '0') { if(t > 0) { t --, ss ++, ans += r - i, r ++; } else { r ++; } } else { ss ++, ans += r - i, r ++; } } } if(ok) { cout << ans; ok = false; } else { cout << ' ' << ans; } } cout << '\n'; }
signed main() { ios::sync_with_stdio(false); cin.tie(nullptr), cout.tie(nullptr); int _ = 1; cin >> _; cout << fixed << setprecision(10); while(_ --) { solve(); } return _ ^ _; }
|