Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Lucas Hernán Tarche - ESCCP - 2020
- //CodeForces
- #include <iostream>
- #include <string>
- #include <vector>
- using namespace std;
- int main() {
- int t, n, k;
- string in;
- cin >> t;
- for (int i = 0; i < t; i++) {
- cin >> n >> k >> in;
- vector<bool> seats(n, true);
- for (int j = 0; j < n; j++) {
- if (in[j] == '1') {
- for (int m = j - k; m <= j + k; m++) {
- if (m < 0 || m >= n) continue;
- seats[m] = false;
- }
- }
- }
- int counter = 0;
- for (int j = 0; j < n; j++) {
- if (seats[j]) {
- counter++;
- for (int m = j - k; m <= j + k; m++) {
- if (m < 0 || m >= n) continue;
- seats[m] = false;
- }
- }
- }
- cout << counter << '\n';
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement