output stringlengths 52 181k | instruction stringlengths 296 182k |
|---|---|
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int t, n, k, cnt;
string s;
cin >> t;
while (t--) {
cin >> n >> k;
cin >> s;
cnt = 0;
if (count(s.begin(), s.end(), '0') == n) {
cout << (int)(ceil((double)(n) ... | ### Prompt
Please formulate a CPP solution to the following problem:
Polycarp and his friends want to visit a new restaurant. The restaurant has n tables arranged along a straight line. People are already sitting at some tables. The tables are numbered from 1 to n in the order from left to right. The state of the res... |
#include <bits/stdc++.h>
using namespace std;
vector<int> vec{};
int numof(string sing, char x) {
map<char, int> nuof;
string a = sing;
for (char c : a) {
nuof[c]++;
}
return nuof[x];
}
int main() {
int a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y,
z, count;
a = b = ... | ### Prompt
Develop a solution in Cpp to the problem described below:
Polycarp and his friends want to visit a new restaurant. The restaurant has n tables arranged along a straight line. People are already sitting at some tables. The tables are numbered from 1 to n in the order from left to right. The state of the res... |
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
const int N = 2e5 + 5;
int t, n, k, ans;
string s;
vector<int> pos;
int main() {
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
cin >> t;
while (t--) {
cin >> n >> k >> s;
for (int i = 0; i < n; i++) {
if (s[i] == '1') pos.p... | ### Prompt
Create a solution in cpp for the following problem:
Polycarp and his friends want to visit a new restaurant. The restaurant has n tables arranged along a straight line. People are already sitting at some tables. The tables are numbered from 1 to n in the order from left to right. The state of the restauran... |
#include <bits/stdc++.h>
using namespace std;
int main() {
int q;
cin >> q;
while (q--) {
int n, k;
cin >> n >> k;
string res;
cin >> res;
int embef = k;
int ans = 0;
for (int i = 0; i < n;) {
if (res[i] == '0' && embef == k) {
int emfor = 0;
for (int j = i + 1; j... | ### Prompt
Please create a solution in CPP to the following problem:
Polycarp and his friends want to visit a new restaurant. The restaurant has n tables arranged along a straight line. People are already sitting at some tables. The tables are numbered from 1 to n in the order from left to right. The state of the res... |
#include <bits/stdc++.h>
using namespace std;
int t, n;
string s;
int main() {
cin >> t;
while (t--) {
int u, ans = 0;
int k;
cin >> n >> k >> s;
u = s.size() + k;
for (int i = s.size() - 1; i >= 0; i--)
if (s[i] - 48) {
ans += (u - i - k - 1) / (k + 1);
u = i;
}
... | ### Prompt
Construct a Cpp code solution to the problem outlined:
Polycarp and his friends want to visit a new restaurant. The restaurant has n tables arranged along a straight line. People are already sitting at some tables. The tables are numbered from 1 to n in the order from left to right. The state of the restau... |
#include <bits/stdc++.h>
using namespace std;
void solve() {
long long int n, k;
cin >> n >> k;
string s;
cin >> s;
set<long long int> st;
for (int i = 0; i < n; i++) {
if (s[i] == '1') st.insert(i);
}
if (st.empty()) {
if (n % (k + 1) == 0)
cout << n / (k + 1) << endl;
else
cout... | ### Prompt
Develop a solution in CPP to the problem described below:
Polycarp and his friends want to visit a new restaurant. The restaurant has n tables arranged along a straight line. People are already sitting at some tables. The tables are numbered from 1 to n in the order from left to right. The state of the res... |
#include <bits/stdc++.h>
using namespace std;
void solve() {
int i, j, k, m, n, ans = 0, cnt = 0;
cin >> n >> k;
string s;
cin >> s;
vector<int> mid;
i = 0;
long long int start = 0;
if (s[start] == '0') {
while (start <= k) {
if (s[start] == '1') break;
start++;
}
if (start == k ... | ### Prompt
Develop a solution in CPP to the problem described below:
Polycarp and his friends want to visit a new restaurant. The restaurant has n tables arranged along a straight line. People are already sitting at some tables. The tables are numbered from 1 to n in the order from left to right. The state of the res... |
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
vector<int> res(t);
for (int i = 0; i < t; i++) {
int n, k;
string s;
cin >> n >> k >> s;
int num0 = 0;
int put = 0;
bool yes1 = false;
for (int j = 0; j < n; j++) {
if (s[j] == '0')
num0 += 1;
... | ### Prompt
Please provide a cpp coded solution to the problem described below:
Polycarp and his friends want to visit a new restaurant. The restaurant has n tables arranged along a straight line. People are already sitting at some tables. The tables are numbered from 1 to n in the order from left to right. The state ... |
#include <bits/stdc++.h>
using namespace std;
int main() {
long long test, n, k;
cin >> test;
while (test--) {
cin >> n >> k;
string a;
long long soln = 0;
cin >> a;
for (int i = 0; i < n;) {
if (a[i] == '1') {
int j = i + 1;
for (; j <= i + k && j < n; j++) {
i... | ### Prompt
Generate a Cpp solution to the following problem:
Polycarp and his friends want to visit a new restaurant. The restaurant has n tables arranged along a straight line. People are already sitting at some tables. The tables are numbered from 1 to n in the order from left to right. The state of the restaurant ... |
#include <bits/stdc++.h>
using namespace std;
using lo = long long int;
int in() {
int a;
cin >> a;
return a;
}
void solve() {
int n, k;
cin >> n >> k;
string s;
cin >> s;
int ans = 0;
for (int i = 0; i < n;) {
int j = i + 1;
for (; j < n && s[j] != '1'; j++)
;
int l = s[i] == '1' ? ... | ### Prompt
Generate a CPP solution to the following problem:
Polycarp and his friends want to visit a new restaurant. The restaurant has n tables arranged along a straight line. People are already sitting at some tables. The tables are numbered from 1 to n in the order from left to right. The state of the restaurant ... |
#include <bits/stdc++.h>
using namespace std;
int32_t main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout << setprecision(9) << fixed;
long long int t;
cin >> t;
while (t--) {
long long int n, k;
cin >> n >> k;
string s;
cin >> s;
vector<long long int> v;
for (long long in... | ### Prompt
Your challenge is to write a cpp solution to the following problem:
Polycarp and his friends want to visit a new restaurant. The restaurant has n tables arranged along a straight line. People are already sitting at some tables. The tables are numbered from 1 to n in the order from left to right. The state ... |
#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) {
if (b == 0) {
return a;
}
return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
long long g = gcd(a, b);
return a / g * b;
}
int main() {
int t;
cin >> t;
while (t--) {
int n, k;
cin >> n >> k... | ### Prompt
Your challenge is to write a cpp solution to the following problem:
Polycarp and his friends want to visit a new restaurant. The restaurant has n tables arranged along a straight line. People are already sitting at some tables. The tables are numbered from 1 to n in the order from left to right. The state ... |
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
int n, k;
cin >> n >> k;
string s;
cin >> s;
int cnt = k, ans = 0;
for (int i = 0; i < n; i++) {
if (s[i] == '0')
cnt++;
else {
ans += (cnt - k) / (k + 1);
cnt = 0;... | ### Prompt
Generate a CPP solution to the following problem:
Polycarp and his friends want to visit a new restaurant. The restaurant has n tables arranged along a straight line. People are already sitting at some tables. The tables are numbered from 1 to n in the order from left to right. The state of the restaurant ... |
#include <bits/stdc++.h>
using namespace std;
const long long M = 1e9 + 7;
const long long MAXN = 1e6 + 7;
const long double pi = acos(-1);
inline long long read() {
long long x = 0, ff = 1;
char ch = getchar();
while (!isdigit(ch)) {
if (ch == '-') ff = -1;
ch = getchar();
}
while (isdigit(ch)) {
... | ### Prompt
Construct a CPP code solution to the problem outlined:
Polycarp and his friends want to visit a new restaurant. The restaurant has n tables arranged along a straight line. People are already sitting at some tables. The tables are numbered from 1 to n in the order from left to right. The state of the restau... |
#include <bits/stdc++.h>
using namespace std;
long long ceill(long long a, long long b) { return a / b + bool(a % b); }
long long gcd(long long a, long long b) {
if (b == 0) return a;
return gcd(b, a % b);
}
long long lcm(long long a, long long b) { return (a * b) / gcd(a, b); }
long long power(long long x, long lo... | ### Prompt
Please create a solution in cpp to the following problem:
Polycarp and his friends want to visit a new restaurant. The restaurant has n tables arranged along a straight line. People are already sitting at some tables. The tables are numbered from 1 to n in the order from left to right. The state of the res... |
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
int n, k;
cin >> n >> k;
string s;
cin >> s;
set<int> q;
for (int i = 0; i < (int)s.size(); i++) {
if (s[i] == '1') q.insert(i);
}
int ans = 0;
for (int i = 0; i < (int)s.size(); i++... | ### Prompt
Generate a Cpp solution to the following problem:
Polycarp and his friends want to visit a new restaurant. The restaurant has n tables arranged along a straight line. People are already sitting at some tables. The tables are numbered from 1 to n in the order from left to right. The state of the restaurant ... |
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
int n, k;
cin >> n >> k;
string s;
cin >> s;
vector<int> ind;
for (int i = 0; i < s.length(); i++) {
if (s[i] == '1') ind.push_back(i);
}
int ans = 0;
if (ind.size() == 0) {
if... | ### Prompt
Your challenge is to write a cpp solution to the following problem:
Polycarp and his friends want to visit a new restaurant. The restaurant has n tables arranged along a straight line. People are already sitting at some tables. The tables are numbered from 1 to n in the order from left to right. The state ... |
#include <bits/stdc++.h>
using namespace std;
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target( \
"sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#pragma GCC optimize("-ffloat-store")
const long long INF = 0xFFFFFFFFFFFFFFFL;
;
const long long N = 1e9 + 7;... | ### Prompt
Please provide a CPP coded solution to the problem described below:
Polycarp and his friends want to visit a new restaurant. The restaurant has n tables arranged along a straight line. People are already sitting at some tables. The tables are numbered from 1 to n in the order from left to right. The state ... |
#include <bits/stdc++.h>
long long int gcd(long long int a, long long int b) {
if (b == 0) return a;
return gcd(b, a % b);
}
long long int exp(long long int x, long long int y, long long int mod) {
long long int res = 1;
x = x % mod;
while (y > 0) {
if (y & 1) res = (res * x) % mod;
y = y >> 1;
x ... | ### Prompt
Construct a cpp code solution to the problem outlined:
Polycarp and his friends want to visit a new restaurant. The restaurant has n tables arranged along a straight line. People are already sitting at some tables. The tables are numbered from 1 to n in the order from left to right. The state of the restau... |
#include <bits/stdc++.h>
#pragma G++ optimize("Ofast")
#pragma G++ optimize("avx")
using namespace std;
void solve() {
long long n, k;
cin >> n >> k;
string s;
cin >> s;
long long ans = 0;
for (long long i = 0; i < n;) {
if (s[i] == '1') {
i++;
continue;
}
long long j = i;
while ... | ### Prompt
Generate a CPP solution to the following problem:
Polycarp and his friends want to visit a new restaurant. The restaurant has n tables arranged along a straight line. People are already sitting at some tables. The tables are numbered from 1 to n in the order from left to right. The state of the restaurant ... |
#include <bits/stdc++.h>
using namespace std;
const int N = 2e6 + 10;
using namespace std;
int cnt[N];
int val(int win, int k) {
int ans = win / (k + 1);
if (win % (k + 1) != 0) ++ans;
return ans;
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
;
int t;
cin >> t;
while (t--) {
... | ### Prompt
Develop a solution in cpp to the problem described below:
Polycarp and his friends want to visit a new restaurant. The restaurant has n tables arranged along a straight line. People are already sitting at some tables. The tables are numbered from 1 to n in the order from left to right. The state of the res... |
#include <bits/stdc++.h>
using ll = long long;
using ld = long double;
using namespace std;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
ll t, n, x, k, l, i, m;
cin >> t;
vector<ll> V;
for (i = 0; i < t; i++) {
cin >> n >> k;
vector<ll> V1;
string s;
cin >> s;
for (l = 0; l < n... | ### Prompt
Your task is to create a cpp solution to the following problem:
Polycarp and his friends want to visit a new restaurant. The restaurant has n tables arranged along a straight line. People are already sitting at some tables. The tables are numbered from 1 to n in the order from left to right. The state of t... |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
int main() {
ios::sync_with_stdio(0), cin.tie(0);
int tt;
cin >> tt;
while (tt--) {
int n, k;
cin >> n >> k;
int ans = 0;
int count = 0;
char x;
int lwb = 0;
bool f = false;
for (int i = 0... | ### Prompt
Your challenge is to write a CPP solution to the following problem:
Polycarp and his friends want to visit a new restaurant. The restaurant has n tables arranged along a straight line. People are already sitting at some tables. The tables are numbered from 1 to n in the order from left to right. The state ... |
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
int n, k;
string s, t;
cin >> n >> k >> s;
t = s;
for (int i = 0; i < n; i++) {
if (t[i] == '1') {
for (int j = i; j <= i + k && j < n; j++) t[j] = '1';
i = i + k;
}
}
... | ### Prompt
Generate a cpp solution to the following problem:
Polycarp and his friends want to visit a new restaurant. The restaurant has n tables arranged along a straight line. People are already sitting at some tables. The tables are numbered from 1 to n in the order from left to right. The state of the restaurant ... |
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int t;
cin >> t;
while (t--) {
int c = 0;
int n, k;
cin >> n >> k;
string s;
cin >> s;
bool arr[n];
for (int i = 0; i < n; i++) {
arr[i] = true;
}
for (int i = ... | ### Prompt
Create a solution in CPP for the following problem:
Polycarp and his friends want to visit a new restaurant. The restaurant has n tables arranged along a straight line. People are already sitting at some tables. The tables are numbered from 1 to n in the order from left to right. The state of the restauran... |
#include <bits/stdc++.h>
using namespace std;
int precheck(vector<char> v, vector<int> &ind, int n, int k) {
int size = ind.size(), ans = 0;
for (int i = 0; i < size - 1; i++) {
if ((ind[i + 1] - ind[i] - 1) < k) return 0;
}
if (size == 0) {
for (int i = 0; i < n; i = i + k + 1) {
ans++;
}
... | ### Prompt
Your challenge is to write a cpp solution to the following problem:
Polycarp and his friends want to visit a new restaurant. The restaurant has n tables arranged along a straight line. People are already sitting at some tables. The tables are numbered from 1 to n in the order from left to right. The state ... |
#include <bits/stdc++.h>
using namespace std;
const int inf = 1e5 + 5;
const double eps = 0;
const int ms = 0;
const int md = 0;
int a[100005];
int mark[100005] = {};
vector<int> res;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int t;
cin >> t;
;
while (t--) {
int n, k;
cin >> n >> k;
... | ### Prompt
Construct a CPP code solution to the problem outlined:
Polycarp and his friends want to visit a new restaurant. The restaurant has n tables arranged along a straight line. People are already sitting at some tables. The tables are numbered from 1 to n in the order from left to right. The state of the restau... |
#include <bits/stdc++.h>
using namespace std;
int main() {
long long int t;
cin >> t;
while (t--) {
long long int n, k;
cin >> n >> k;
string s;
cin >> s;
long long int ans = 0;
vector<long long int> ind;
for (int i = 0; i < s.length(); i++) {
if (s[i] == '1') ind.push_back(i + 1... | ### Prompt
Your challenge is to write a Cpp solution to the following problem:
Polycarp and his friends want to visit a new restaurant. The restaurant has n tables arranged along a straight line. People are already sitting at some tables. The tables are numbered from 1 to n in the order from left to right. The state ... |
#include <bits/stdc++.h>
using namespace std;
void solve() {
int n, k;
cin >> n >> k;
string s;
cin >> s;
for (int i = 0; i < n; ++i) {
if (s[i] == '1') {
for (int j = max(0, i - k); j <= (min(i + k, n - 1)); j++) {
if (s[j] == '0') s[j] = 'w';
}
}
}
int ans = 0;
for (int i =... | ### Prompt
Your challenge is to write a Cpp solution to the following problem:
Polycarp and his friends want to visit a new restaurant. The restaurant has n tables arranged along a straight line. People are already sitting at some tables. The tables are numbered from 1 to n in the order from left to right. The state ... |
#include <bits/stdc++.h>
using namespace std;
int n, k;
string s;
void solve() {}
int main() {
std::ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
long long test = 1;
cin >> test;
while (test--) {
cin >> n >> k;
cin >> s;
int ans = 0;
int cnt = 0;
for (long long i = 0; i < (n... | ### Prompt
In CPP, your task is to solve the following problem:
Polycarp and his friends want to visit a new restaurant. The restaurant has n tables arranged along a straight line. People are already sitting at some tables. The tables are numbered from 1 to n in the order from left to right. The state of the restaura... |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T, class U>
ostream& operator<<(ostream& o, const pair<T, U>& p) {
o << "(" << p.first << "," << p.second << ")";
return o;
}
template <class T>
ostream& operator<<(ostream& o, const vector<T>& v) {
o << "[";
for (T t : v) {
... | ### Prompt
Please formulate a cpp solution to the following problem:
Polycarp and his friends want to visit a new restaurant. The restaurant has n tables arranged along a straight line. People are already sitting at some tables. The tables are numbered from 1 to n in the order from left to right. The state of the res... |
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
long long int t = 1;
cin >> t;
while (t--) {
long long int n, k;
cin >> n >> k;
string s, s1;
cin >> s;
for (long long int i = 1; i <= k; i++) {
s1 += "0";
}
s ... | ### Prompt
Generate a Cpp solution to the following problem:
Polycarp and his friends want to visit a new restaurant. The restaurant has n tables arranged along a straight line. People are already sitting at some tables. The tables are numbered from 1 to n in the order from left to right. The state of the restaurant ... |
#include <bits/stdc++.h>
using namespace std;
long long MOD = 1e9 + 7;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
;
int t;
cin >> t;
while (t != 0) {
t--;
int n, k, l = -1, r = -1;
cin >> n >> k;
int c = k + 1, z, res = 0;
string x;
cin >> x;
... | ### Prompt
Please provide a Cpp coded solution to the problem described below:
Polycarp and his friends want to visit a new restaurant. The restaurant has n tables arranged along a straight line. People are already sitting at some tables. The tables are numbered from 1 to n in the order from left to right. The state ... |
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC target("sse4")
using namespace std;
int sum() { return 0; }
template <typename T, typename... Args>
T sum(T a, Args... args) {
return a + sum(args...);
}
int tt, n, k;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >>... | ### Prompt
In Cpp, your task is to solve the following problem:
Polycarp and his friends want to visit a new restaurant. The restaurant has n tables arranged along a straight line. People are already sitting at some tables. The tables are numbered from 1 to n in the order from left to right. The state of the restaura... |
#include <bits/stdc++.h>
using namespace std;
int main() {
int test;
cin >> test;
while (test--) {
long long int n, k;
cin >> n >> k;
string a;
cin >> a;
vector<long long int> v;
v.push_back(0);
for (long long int i = 0; i < n; i++) {
if (a[i] == '1') v.push_back(i);
}
v.... | ### Prompt
Develop a solution in cpp to the problem described below:
Polycarp and his friends want to visit a new restaurant. The restaurant has n tables arranged along a straight line. People are already sitting at some tables. The tables are numbered from 1 to n in the order from left to right. The state of the res... |
#include <bits/stdc++.h>
using namespace std;
int main() {
int t, n, k, l, cn, m, w;
string s;
vector<int> v;
cin >> t;
for (int z = 0; z < t; z++) {
l = 0;
cn = 0;
m = 0;
cin >> n >> k;
cin >> s;
for (int i = 0; i < s.size(); i++) {
if (s[i] == '1') {
l++;
v.push... | ### Prompt
Please create a solution in cpp to the following problem:
Polycarp and his friends want to visit a new restaurant. The restaurant has n tables arranged along a straight line. People are already sitting at some tables. The tables are numbered from 1 to n in the order from left to right. The state of the res... |
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int t;
cin >> t;
while (t--) {
int i, n, a[200005] = {0}, k = 0, m = 0, v = 0, e = 0, o = 0;
cin >> n >> k;
string s;
cin >> s;
for (i = 0; i < n; i++) {
if (s[i] == '1') {
... | ### Prompt
Please provide a Cpp coded solution to the problem described below:
Polycarp and his friends want to visit a new restaurant. The restaurant has n tables arranged along a straight line. People are already sitting at some tables. The tables are numbered from 1 to n in the order from left to right. The state ... |
#include <bits/stdc++.h>
using namespace std;
void fun() {}
long long int md = 1e9 + 7;
long long int __gcd(long long int a, long long int b) {
if (b == 0) return a;
return __gcd(b, a % b);
}
long long int poww(long long int a, long long int b, long long int md) {
if (b < 0) return 0;
if (a == 0) return 0;
lo... | ### Prompt
Generate a Cpp solution to the following problem:
Polycarp and his friends want to visit a new restaurant. The restaurant has n tables arranged along a straight line. People are already sitting at some tables. The tables are numbered from 1 to n in the order from left to right. The state of the restaurant ... |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using Vi = vector<int>;
void run() {
int n, d, first = -1, one = 0;
cin >> n >> d;
string s;
cin >> s;
for (int i = 0; i < s.size(); ++i) {
if (s[i] == '1') {
first = i;
break;
}
}
if (f... | ### Prompt
Create a solution in CPP for the following problem:
Polycarp and his friends want to visit a new restaurant. The restaurant has n tables arranged along a straight line. People are already sitting at some tables. The tables are numbered from 1 to n in the order from left to right. The state of the restauran... |
#include <bits/stdc++.h>
using namespace std;
int main() {
long long int t, n, k, b = 0, c = 0, d = 0, e, i, j, x, y, m, m1, mp, m2, r;
cin >> t;
string s;
for (j = 0; j < t; j++) {
vector<long long int> v;
cin >> n >> k;
cin >> s;
for (i = 0; i < s.size(); i++) {
if (s[i] == '1') {
... | ### Prompt
Create a solution in cpp for the following problem:
Polycarp and his friends want to visit a new restaurant. The restaurant has n tables arranged along a straight line. People are already sitting at some tables. The tables are numbered from 1 to n in the order from left to right. The state of the restauran... |
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
int n, k;
cin >> n >> k;
string s;
cin >> s;
vector<int> vec;
for (int i = 0; i < n; i++) {
if (s[i] == '1') {
vec.push_back(i);
}
}
int m = vec.size();
if (m == 0) {
... | ### Prompt
Please formulate a Cpp solution to the following problem:
Polycarp and his friends want to visit a new restaurant. The restaurant has n tables arranged along a straight line. People are already sitting at some tables. The tables are numbered from 1 to n in the order from left to right. The state of the res... |
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
const int mod = 1e9 + 7;
long long a[N], b, c, d, dis;
pair<int, int> p;
bool mark = true;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int t, n, m, k, ans = 0, sum = 0, mn = 1e8, mx = 0, x, y;
cin >> t;
string s;
while (t--) {
... | ### Prompt
Construct a Cpp code solution to the problem outlined:
Polycarp and his friends want to visit a new restaurant. The restaurant has n tables arranged along a straight line. People are already sitting at some tables. The tables are numbered from 1 to n in the order from left to right. The state of the restau... |
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
int n, k, ans = 0;
string s;
cin >> n >> k >> s;
for (int i = 0; i < n; ++i) {
if (s[i] == '1') {
for (int j = i + 1; j < min(i + k + 1, n); ++j) {
s[j] = 'x';
}
}
}
... | ### Prompt
Create a solution in Cpp for the following problem:
Polycarp and his friends want to visit a new restaurant. The restaurant has n tables arranged along a straight line. People are already sitting at some tables. The tables are numbered from 1 to n in the order from left to right. The state of the restauran... |
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
int pre[N];
void solve() {
string s;
int n, k, ans = 0;
cin >> n >> k >> s;
for (int i = 0; i < n; i++) {
if (s[i] == '1') {
if (i == 0)
pre[i] = 1;
else
pre[i] = pre[i - 1] + 1;
} else {
if (i == 0)
... | ### Prompt
Develop a solution in cpp to the problem described below:
Polycarp and his friends want to visit a new restaurant. The restaurant has n tables arranged along a straight line. People are already sitting at some tables. The tables are numbered from 1 to n in the order from left to right. The state of the res... |
#include <bits/stdc++.h>
using namespace std;
long long fx[4] = {1, -1, 0, 0};
long long fy[4] = {0, 0, 1, -1};
long long ox8[] = {0, 0, 1, 1, 1, -1, -1, -1};
long long oy8[] = {1, -1, 1, -1, 0, 0, -1, 1};
bool sortinrev(const pair<int, int> &a, const pair<int, int> &b) {
return a.first > b.first;
}
long long pw(long... | ### Prompt
Create a solution in CPP for the following problem:
Polycarp and his friends want to visit a new restaurant. The restaurant has n tables arranged along a straight line. People are already sitting at some tables. The tables are numbered from 1 to n in the order from left to right. The state of the restauran... |
#include <bits/stdc++.h>
using namespace std;
void solve() {
long long n, k;
cin >> n >> k;
string s;
cin >> s;
vector<long long> l_r, r_l;
long long count = k + 1;
for (long long i = 0; i < n; i++) {
if (s[i] == '1') {
count = 0;
l_r.push_back(0);
} else if (s[i] == '0') {
count... | ### Prompt
In cpp, your task is to solve the following problem:
Polycarp and his friends want to visit a new restaurant. The restaurant has n tables arranged along a straight line. People are already sitting at some tables. The tables are numbered from 1 to n in the order from left to right. The state of the restaura... |
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
int i, n, k, t = 0;
cin >> n >> k;
int d = k;
char ch;
for (i = 1; i <= n; i++) {
cin >> ch;
if (ch == '0') {
d++;
} else {
d -= k;
t += d / (k + 1);
d = ... | ### Prompt
Develop a solution in Cpp to the problem described below:
Polycarp and his friends want to visit a new restaurant. The restaurant has n tables arranged along a straight line. People are already sitting at some tables. The tables are numbered from 1 to n in the order from left to right. The state of the res... |
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int t;
cin >> t;
while (t--) {
int n, k;
cin >> n >> k;
string s, pad = "";
cin >> s;
for (int i = 0; i < (k); i++) pad += '0';
s = pad + s + pad;
int ans... | ### Prompt
Construct a cpp code solution to the problem outlined:
Polycarp and his friends want to visit a new restaurant. The restaurant has n tables arranged along a straight line. People are already sitting at some tables. The tables are numbered from 1 to n in the order from left to right. The state of the restau... |
#include <bits/stdc++.h>
using namespace std;
#pragma GCC target("avx2")
#pragma GCC optimization("O3")
#pragma GCC optimization("unroll-loops")
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
long long int t;
cin >> t;
while (t--) {
int n, k;
cin >> n >> k;
string s;
cin >> s;
... | ### Prompt
Please formulate a cpp solution to the following problem:
Polycarp and his friends want to visit a new restaurant. The restaurant has n tables arranged along a straight line. People are already sitting at some tables. The tables are numbered from 1 to n in the order from left to right. The state of the res... |
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
int n, k;
string s;
cin >> n >> k >> s;
int L = k, res = 0;
for (char c : s) {
if (c == '0')
L += 1;
else {
res += (L - k) / (k + 1);
L = 0;
}
}
res += L ... | ### Prompt
Your challenge is to write a Cpp solution to the following problem:
Polycarp and his friends want to visit a new restaurant. The restaurant has n tables arranged along a straight line. People are already sitting at some tables. The tables are numbered from 1 to n in the order from left to right. The state ... |
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
long long int n, cnt = 0, c = 0, k, sum = 0;
string ar;
cin >> n >> k;
cin >> ar;
for (int i = 0; i < n; i++) {
if (ar[i] == '1') sum++;
if (ar[i] == '1' && i == 0) cnt++;
if (ar[i] == '... | ### Prompt
Please provide a cpp coded solution to the problem described below:
Polycarp and his friends want to visit a new restaurant. The restaurant has n tables arranged along a straight line. People are already sitting at some tables. The tables are numbered from 1 to n in the order from left to right. The state ... |
#include <bits/stdc++.h>
using namespace std;
int check(int m, int k, string s) {
int i;
for (i = m + 1; i <= m + k && i < s.size(); i++) {
if (s[i] == '1') return i;
}
return -1;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int t;
cin >> t;
while (t > 0) {
int i... | ### Prompt
Generate a Cpp solution to the following problem:
Polycarp and his friends want to visit a new restaurant. The restaurant has n tables arranged along a straight line. People are already sitting at some tables. The tables are numbered from 1 to n in the order from left to right. The state of the restaurant ... |
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("-ffloat-store")
using namespace std;
const long long mod = 998244353;
long long powmod(long long a, long long b) {
long long res = 1;
a %= mod;
assert(b >= 0);... | ### Prompt
Your task is to create a CPP solution to the following problem:
Polycarp and his friends want to visit a new restaurant. The restaurant has n tables arranged along a straight line. People are already sitting at some tables. The tables are numbered from 1 to n in the order from left to right. The state of t... |
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int test;
cin >> test;
while (test--) {
int n;
cin >> n;
int k;
cin >> k;
string s;
cin >> s;
vector<int> val;
val.push_back(-k - 1);
for (int i = 0; i < n; i++) {
... | ### Prompt
Please provide a cpp coded solution to the problem described below:
Polycarp and his friends want to visit a new restaurant. The restaurant has n tables arranged along a straight line. People are already sitting at some tables. The tables are numbered from 1 to n in the order from left to right. The state ... |
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
int n, k, a = 0, j;
cin >> n >> k;
string s;
cin >> s;
int cnt = 0;
for (int i = 0; i < n; i++) {
if (s[i] == '1') {
a++;
if (a == 1) cnt = cnt + i / (k + 1);
for (j = i ... | ### Prompt
Create a solution in CPP for the following problem:
Polycarp and his friends want to visit a new restaurant. The restaurant has n tables arranged along a straight line. People are already sitting at some tables. The tables are numbered from 1 to n in the order from left to right. The state of the restauran... |
#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
char str[maxn];
int sum[maxn];
int n, k;
inline int lowbit(int x) { return -x & x; }
void add(int x, int y) {
while (x <= n) {
sum[x] += y;
x += lowbit(x);
}
}
int ask(int x) {
int res = 0;
while (x) {
res += sum[x];
x -= l... | ### Prompt
Create a solution in CPP for the following problem:
Polycarp and his friends want to visit a new restaurant. The restaurant has n tables arranged along a straight line. People are already sitting at some tables. The tables are numbered from 1 to n in the order from left to right. The state of the restauran... |
#include <bits/stdc++.h>
int pmod(int n, int m) { return (n % m + m) % m; }
int next(int n, int m) { return n + pmod(-n, m); }
int main() {
int t;
std::cin >> t;
while (t--) {
int n, k;
std::cin >> n >> k;
std::string str;
std::cin >> str;
std::string oth(str.size(), '0');
int c = 0;
f... | ### Prompt
In CPP, your task is to solve the following problem:
Polycarp and his friends want to visit a new restaurant. The restaurant has n tables arranged along a straight line. People are already sitting at some tables. The tables are numbered from 1 to n in the order from left to right. The state of the restaura... |
#include <bits/stdc++.h>
using namespace std;
void solve() {
long long n, k;
cin >> n >> k;
string s;
cin >> s;
long long c = 0;
long long po = 0;
for (long long i = 0; i < n; i++) {
if (s[i] == 49) {
c++;
po = i;
}
}
long long dist = 0;
long long cnt = 1;
for (long long i = 0;... | ### Prompt
Generate a Cpp solution to the following problem:
Polycarp and his friends want to visit a new restaurant. The restaurant has n tables arranged along a straight line. People are already sitting at some tables. The tables are numbered from 1 to n in the order from left to right. The state of the restaurant ... |
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
int n, k;
cin >> n >> k;
string s;
cin >> s;
vector<int> l(n);
vector<int> r(n);
int cur = -1;
for (int i = 0; i < n; i++) {
if (s[i] == '1') {
cur = i;
}
l[i] = cur;... | ### Prompt
In cpp, your task is to solve the following problem:
Polycarp and his friends want to visit a new restaurant. The restaurant has n tables arranged along a straight line. People are already sitting at some tables. The tables are numbered from 1 to n in the order from left to right. The state of the restaura... |
#include <bits/stdc++.h>
using namespace std;
void solve() {
long long n, k;
cin >> n >> k;
string str;
cin >> str;
long long pos = 0;
bool one = false;
long long ans = 0;
long long fi = 0;
long long si = -1;
long long zero = 0;
for (int i = 0; i < str.length(); i++) {
if (str[i] == '0') {
... | ### Prompt
Create a solution in cpp for the following problem:
Polycarp and his friends want to visit a new restaurant. The restaurant has n tables arranged along a straight line. People are already sitting at some tables. The tables are numbered from 1 to n in the order from left to right. The state of the restauran... |
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int t;
cin >> t;
while (t--) {
int z = 0;
int o = 0;
int ans = 0;
int n, k;
cin >> n >> k;
int a[n];
char x;
for (int i = 0; i < n; i++) {
cin >> ... | ### Prompt
Your challenge is to write a cpp solution to the following problem:
Polycarp and his friends want to visit a new restaurant. The restaurant has n tables arranged along a straight line. People are already sitting at some tables. The tables are numbered from 1 to n in the order from left to right. The state ... |
#include <bits/stdc++.h>
using namespace std;
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
long long T;
cin >> T;
while (T--) {
long long n, k, i, ans = 0;
cin >> n >> k;
char s[n];
long long count = k;
cin >> s;
for (i = 0; i < n; i++) {
if (s[i] == '0') {
... | ### Prompt
Please formulate a cpp solution to the following problem:
Polycarp and his friends want to visit a new restaurant. The restaurant has n tables arranged along a straight line. People are already sitting at some tables. The tables are numbered from 1 to n in the order from left to right. The state of the res... |
#include <bits/stdc++.h>
using namespace std;
int t;
int n, k;
char s[255555];
int Sum[555555];
int main() {
scanf("%d", &t);
while (t--) {
scanf("%d%d", &n, &k);
scanf("%s", s + 1);
for (int i = 1; i <= n + k; i++) Sum[i] = Sum[i - 1] + s[i] == '1';
int cnt = 0;
for (int i = 1; i <= n; i++) {
... | ### Prompt
Please provide a Cpp coded solution to the problem described below:
Polycarp and his friends want to visit a new restaurant. The restaurant has n tables arranged along a straight line. People are already sitting at some tables. The tables are numbered from 1 to n in the order from left to right. The state ... |
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimization("Ofast")
#pragma GCC optimization("unroll-loops")
#pragma GCC target("avx2,avx,fma")
const long long N = 200005;
int dir4[4][2] = {{1, 0}, {-1, 0}, {0, -1}, {0, 1}};
int dir8[8][2] = {{1, 0}, {-1, 0}, {0, -1}, {0, 1},
{1, 1}, {-1, ... | ### Prompt
Construct a CPP code solution to the problem outlined:
Polycarp and his friends want to visit a new restaurant. The restaurant has n tables arranged along a straight line. People are already sitting at some tables. The tables are numbered from 1 to n in the order from left to right. The state of the restau... |
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
int n, k;
cin >> n >> k;
string s;
cin >> s;
int last = -1000000;
int ans = 0;
for (int i = 0; i < n; i++) {
if (s[i] == '1') {
if (i - last <= k) ans--;
last = i;
} el... | ### Prompt
Your challenge is to write a CPP solution to the following problem:
Polycarp and his friends want to visit a new restaurant. The restaurant has n tables arranged along a straight line. People are already sitting at some tables. The tables are numbered from 1 to n in the order from left to right. The state ... |
#include <bits/stdc++.h>
using namespace std;
const int N = 1005;
const long long inf = 1e18;
const long long mod = 1e9 + 7;
const int INF = 1 << 30;
const double eps = (1e-10);
void dg(long long ok) { cout << ok << endl; }
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
ios_base::sync_with_stdio(0);
int tc;
... | ### Prompt
Please formulate a CPP solution to the following problem:
Polycarp and his friends want to visit a new restaurant. The restaurant has n tables arranged along a straight line. People are already sitting at some tables. The tables are numbered from 1 to n in the order from left to right. The state of the res... |
#include <bits/stdc++.h>
using namespace std;
void solve() {
int n, k, sz = 0, rez = 0;
cin >> n >> k;
string a;
cin >> a;
vector<int> pos;
for (int i = 0; i < n; ++i) {
if (a[i] == '1') pos.push_back(i), sz++;
}
for (int i = 0; i < sz; ++i) {
if (i == 0) {
int ln = pos[i];
ln -= k;
... | ### Prompt
Please formulate a CPP solution to the following problem:
Polycarp and his friends want to visit a new restaurant. The restaurant has n tables arranged along a straight line. People are already sitting at some tables. The tables are numbered from 1 to n in the order from left to right. The state of the res... |
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
for (int pop = 0; pop < t; pop++) {
long long q, k;
cin >> q >> k;
string s;
cin >> s;
long long i = 0;
long long res = 0;
while (i < q) {
if (s[i] == '1') {
i += k;
} else {
int p =... | ### Prompt
Your task is to create a cpp solution to the following problem:
Polycarp and his friends want to visit a new restaurant. The restaurant has n tables arranged along a straight line. People are already sitting at some tables. The tables are numbered from 1 to n in the order from left to right. The state of t... |
#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
const int N = 1000005;
class cmp {
public:
bool operator()(pair<long long, pair<long long, long long> > &A,
pair<long long, pair<long long, long long> > &B) {
return A > B;
}
};
bool by_sec(pair<long long, long long> &A... | ### Prompt
Your task is to create a CPP solution to the following problem:
Polycarp and his friends want to visit a new restaurant. The restaurant has n tables arranged along a straight line. People are already sitting at some tables. The tables are numbered from 1 to n in the order from left to right. The state of t... |
#include <bits/stdc++.h>
using namespace std;
long long pp = 1e9 + 7;
double pi = 3.141592653589793238;
int main() {
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
};
long long t;
cin >> t;
while (t--) {
long long n, k;
cin >> n >> k;
string s;
cin >> s;
long long c = 0;
lo... | ### Prompt
Your challenge is to write a cpp solution to the following problem:
Polycarp and his friends want to visit a new restaurant. The restaurant has n tables arranged along a straight line. People are already sitting at some tables. The tables are numbered from 1 to n in the order from left to right. The state ... |
#include <bits/stdc++.h>
char a[200009];
int b[200009];
int main() {
int t;
scanf("%d", &t);
int n, k;
while (t--) {
scanf("%d%d", &n, &k);
getchar();
scanf("%s", a);
memset(b, 0, sizeof(b));
int len = 0;
int flag = 0;
for (len; a[len] != '\0'; len++)
;
for (int i = 0; a[i]... | ### Prompt
Develop a solution in CPP to the problem described below:
Polycarp and his friends want to visit a new restaurant. The restaurant has n tables arranged along a straight line. People are already sitting at some tables. The tables are numbered from 1 to n in the order from left to right. The state of the res... |
#include <bits/stdc++.h>
using namespace std;
long long int pow1(long long int n, long long int p) {
if (p == 0) return 1;
long long int x = pow1(n, p / 2);
x = (x * x) % 1000000007;
if (p % 2 == 0) return x;
return (x * n) % 1000000007;
}
void solve() {
long long int n, k;
cin >> n >> k;
string s;
ci... | ### Prompt
Construct a CPP code solution to the problem outlined:
Polycarp and his friends want to visit a new restaurant. The restaurant has n tables arranged along a straight line. People are already sitting at some tables. The tables are numbered from 1 to n in the order from left to right. The state of the restau... |
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
for (int test = 0; test < t; ++test) {
int n, k;
cin >> n >> k;
char* res = new char[n + 3];
cin >> res;
int e = 0;
for (int i = 0; i < n;) {
if (res[i] == '1') {
i += (k + 1);
continue;
... | ### Prompt
Please create a solution in cpp to the following problem:
Polycarp and his friends want to visit a new restaurant. The restaurant has n tables arranged along a straight line. People are already sitting at some tables. The tables are numbered from 1 to n in the order from left to right. The state of the res... |
#include <bits/stdc++.h>
using namespace std;
int main() {
int T;
cin >> T;
string s;
while (T--) {
int n, k;
int sum = 0;
cin >> n >> k;
cin >> s;
int x = 0, y = 0;
if (s[x] == '0') x--;
do {
y = x + 1;
while (s[y] == '0' && y < n) y++;
if (x == -1 && y == n) {
... | ### Prompt
Construct a Cpp code solution to the problem outlined:
Polycarp and his friends want to visit a new restaurant. The restaurant has n tables arranged along a straight line. People are already sitting at some tables. The tables are numbered from 1 to n in the order from left to right. The state of the restau... |
#include <bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimization("O3")
#pragma GCC optimization("unroll-loops")
using namespace std;
const long long N = 1e5 + 10;
const long double Pie = acos(-1);
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
long long t;
cin >> ... | ### Prompt
Please create a solution in cpp to the following problem:
Polycarp and his friends want to visit a new restaurant. The restaurant has n tables arranged along a straight line. People are already sitting at some tables. The tables are numbered from 1 to n in the order from left to right. The state of the res... |
#include <bits/stdc++.h>
using namespace std;
void _print(long long t) { cerr << t; }
void _print(int t) { cerr << t; }
void _print(string t) { cerr << t; }
void _print(char t) { cerr << t; }
void _print(long double t) { cerr << t; }
void _print(double t) { cerr << t; }
void _print(unsigned long long t) { cerr << t; }
... | ### Prompt
Develop a solution in CPP to the problem described below:
Polycarp and his friends want to visit a new restaurant. The restaurant has n tables arranged along a straight line. People are already sitting at some tables. The tables are numbered from 1 to n in the order from left to right. The state of the res... |
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 7;
int T, n, k, pre[N];
string s;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
for (cin >> T; T--;) {
cin >> n >> k;
cin >> s;
memset(pre, 0, sizeof(pre));
for (int i = 1; i <= n; i++) {
pre[i] = (s[i - 1] == '1');
... | ### Prompt
Your task is to create a cpp solution to the following problem:
Polycarp and his friends want to visit a new restaurant. The restaurant has n tables arranged along a straight line. People are already sitting at some tables. The tables are numbered from 1 to n in the order from left to right. The state of t... |
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
int n, k;
cin >> n >> k;
string arr;
cin >> arr;
int ans = 0;
int cnt = k;
for (int i = 0; i < n; i++) {
if (arr[i] == '0') {
cnt++;
} else {
ans += (cnt - k) / (k + 1)... | ### Prompt
Generate a Cpp solution to the following problem:
Polycarp and his friends want to visit a new restaurant. The restaurant has n tables arranged along a straight line. People are already sitting at some tables. The tables are numbered from 1 to n in the order from left to right. The state of the restaurant ... |
#include <bits/stdc++.h>
using namespace std;
const long long int INF = 1e13;
const long long int N = 1e4 + 5, D = 105;
const long long int mod = 1e9 + 7;
void solve() {
long long int n, k;
cin >> n >> k;
string s;
cin >> s;
for (long long int i = 0; i < n; i++)
if (s[i] == '1')
for (long long int j... | ### Prompt
Construct a cpp code solution to the problem outlined:
Polycarp and his friends want to visit a new restaurant. The restaurant has n tables arranged along a straight line. People are already sitting at some tables. The tables are numbered from 1 to n in the order from left to right. The state of the restau... |
#include <bits/stdc++.h>
using namespace std;
int cnt, ans;
int k, n;
bool issafe(string &s, int &i) {
int l, r;
if (i - k <= 0)
l = 0;
else
l = i - k;
if (i + k > n - 1)
r = s.length() - 1;
else
r = i + k;
while (l <= r) {
if (s[l] == '1') {
i = l;
return false;
}
l+... | ### Prompt
Generate a cpp solution to the following problem:
Polycarp and his friends want to visit a new restaurant. The restaurant has n tables arranged along a straight line. People are already sitting at some tables. The tables are numbered from 1 to n in the order from left to right. The state of the restaurant ... |
#include <bits/stdc++.h>
using namespace std;
long long int answer(long long int n, long long int k) {
if (n % (k + 1) == 0)
return n / (k + 1);
else
return n / (k + 1) + 1;
}
int main() {
long long int t;
cin >> t;
while (t--) {
long long int n, k;
cin >> n >> k;
string str;
cin >> st... | ### Prompt
Your task is to create a cpp solution to the following problem:
Polycarp and his friends want to visit a new restaurant. The restaurant has n tables arranged along a straight line. People are already sitting at some tables. The tables are numbered from 1 to n in the order from left to right. The state of t... |
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
int n, k;
cin >> n >> k;
string s;
cin >> s;
vector<int> v;
int p = 0;
for (int i = 0; i < s.length(); i++) {
if (s[i] == '1') v.push_back(i);
}
v.push_back(1000000);
int l_one =... | ### Prompt
Create a solution in Cpp for the following problem:
Polycarp and his friends want to visit a new restaurant. The restaurant has n tables arranged along a straight line. People are already sitting at some tables. The tables are numbered from 1 to n in the order from left to right. The state of the restauran... |
#include <bits/stdc++.h>
using namespace std;
const int size1 = 1005;
const int size2 = 55;
const long long mod = 1e9 + 7;
long long n, k;
long long func(long long val) {
if (val <= 0) return 0;
long long ans = val / (k + 1);
if (val % (k + 1) != 0) ans++;
return ans;
}
int main() {
ios_base::sync_with_stdio(... | ### Prompt
Please formulate a Cpp solution to the following problem:
Polycarp and his friends want to visit a new restaurant. The restaurant has n tables arranged along a straight line. People are already sitting at some tables. The tables are numbered from 1 to n in the order from left to right. The state of the res... |
#include <bits/stdc++.h>
using namespace std;
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
int t;
cin >> t;
int n, k;
string s;
while (t--) {
cin >> n >> k >> s;
vector<int> A(n + 1);
for (int i = 0; i < (int)(n); i++) {
if (s[i] == '1') {
A[max(0, i - k)]++;
A[m... | ### Prompt
Your task is to create a cpp solution to the following problem:
Polycarp and his friends want to visit a new restaurant. The restaurant has n tables arranged along a straight line. People are already sitting at some tables. The tables are numbered from 1 to n in the order from left to right. The state of t... |
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(NULL);
int t;
cin >> t;
while (t--) {
int n, k, cnt = 0, ans = 0;
;
cin >> n >> k;
string s;
cin >> s;
for (int i = 0; i < n; ++i)
if (s[i] == '1')
for (int j = i + 1; j < n &&... | ### Prompt
Construct a Cpp code solution to the problem outlined:
Polycarp and his friends want to visit a new restaurant. The restaurant has n tables arranged along a straight line. People are already sitting at some tables. The tables are numbered from 1 to n in the order from left to right. The state of the restau... |
#include <bits/stdc++.h>
using namespace std;
long long func(long long l, long long r, long long k) {
if (l > r) return 0;
long long len = r - l + 1;
long long d = len / (k + 1) + min((long long)1, len % (k + 1));
return d;
}
void solve() {
long long n, k;
cin >> n >> k;
string s;
cin >> s;
long long ... | ### Prompt
Generate a CPP solution to the following problem:
Polycarp and his friends want to visit a new restaurant. The restaurant has n tables arranged along a straight line. People are already sitting at some tables. The tables are numbered from 1 to n in the order from left to right. The state of the restaurant ... |
#include <bits/stdc++.h>
using namespace std;
int main() {
int t, n, k;
string s;
cin >> t;
while (t--) {
cin >> n >> k >> s;
int l, r, cnt = 0;
bool first = true, last = false;
while (true) {
l = s.find('0');
if (l != 0) first = false;
if (l == -1) break;
s = s.substr(l,... | ### Prompt
Please formulate a CPP solution to the following problem:
Polycarp and his friends want to visit a new restaurant. The restaurant has n tables arranged along a straight line. People are already sitting at some tables. The tables are numbered from 1 to n in the order from left to right. The state of the res... |
#include <bits/stdc++.h>
using namespace std;
long long t, n, a[200009], f, k, ans, z, C, one, l, r, xx;
string s;
int main() {
cin >> t;
while (t--) {
cin >> n >> k >> s;
one = 0;
for (int i = 0; i < n; i++)
if (s[i] == '1') one++;
if (!one) {
xx = ceil(n / ((k + 1ll) * (1.0))) * 1ll;
... | ### Prompt
Your task is to create a Cpp solution to the following problem:
Polycarp and his friends want to visit a new restaurant. The restaurant has n tables arranged along a straight line. People are already sitting at some tables. The tables are numbered from 1 to n in the order from left to right. The state of t... |
#include <bits/stdc++.h>
using namespace std;
int func(string &a, int k) {
int n = a.size();
int count = 0, total = 0;
if (a[0] == '0') {
count = k + 1;
}
for (int i = 1; i < n; i++) {
if (a[i] == '0') {
count++;
} else {
count = 0;
}
if (count == 2 * k + 1) {
total++;
... | ### Prompt
Please create a solution in cpp to the following problem:
Polycarp and his friends want to visit a new restaurant. The restaurant has n tables arranged along a straight line. People are already sitting at some tables. The tables are numbered from 1 to n in the order from left to right. The state of the res... |
#include <bits/stdc++.h>
using namespace std;
const long long INF64 = 1e18;
clock_t time_p = clock();
void time() {
time_p = clock() - time_p;
cerr << "Time Taken : " << (float)(time_p) / CLOCKS_PER_SEC << "\n";
}
void doc() {
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
}
void fast() {... | ### Prompt
Your task is to create a cpp solution to the following problem:
Polycarp and his friends want to visit a new restaurant. The restaurant has n tables arranged along a straight line. People are already sitting at some tables. The tables are numbered from 1 to n in the order from left to right. The state of t... |
#include <bits/stdc++.h>
long long sol(long long a, long long b, long long k) {
if (b - a >= 2 * k + 2) {
return ((b - a) - 2 * k - 2) / (k + 1) + 1;
}
return 0;
}
long long max(long long a, long long b) {
if (a < b) return b;
return a;
}
int main() {
long long t, n, i, j, k, pos[200000], ind, tot;
ch... | ### Prompt
Please formulate a Cpp solution to the following problem:
Polycarp and his friends want to visit a new restaurant. The restaurant has n tables arranged along a straight line. People are already sitting at some tables. The tables are numbered from 1 to n in the order from left to right. The state of the res... |
#include <bits/stdc++.h>
template <class T>
T gcd(T a, T b) {
T r;
while (b != 0) {
r = a % b;
a = b;
b = r;
}
return a;
}
template <class T>
T lcm(T a, T b) {
return a / gcd(a, b) * b;
}
template <class T>
T sqr(T x) {
return x * x;
}
template <class T>
T cube(T x) {
return x * x * x;
}
templ... | ### Prompt
Please formulate a CPP solution to the following problem:
Polycarp and his friends want to visit a new restaurant. The restaurant has n tables arranged along a straight line. People are already sitting at some tables. The tables are numbered from 1 to n in the order from left to right. The state of the res... |
#include <bits/stdc++.h>
using namespace std;
void sol() {}
int KO(string s) {
int cnt = 0;
for (int i = 0; i < s.length(); i++) {
if (s[i] == '1') {
cnt++;
}
}
return cnt;
}
int main() {
int t;
cin >> t;
while (t--) {
int n, k;
cin >> n >> k;
string s;
cin >> s;
int p = ... | ### Prompt
In cpp, your task is to solve the following problem:
Polycarp and his friends want to visit a new restaurant. The restaurant has n tables arranged along a straight line. People are already sitting at some tables. The tables are numbered from 1 to n in the order from left to right. The state of the restaura... |
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int t;
cin >> t;
while (t--) {
int n, k;
cin >> n >> k;
string s;
cin >> s;
int count = 0, max = 0;
for (int i = 0; i < n;) {
if (s[i] == '0') {
for (int j = i + 1;... | ### Prompt
Create a solution in Cpp for the following problem:
Polycarp and his friends want to visit a new restaurant. The restaurant has n tables arranged along a straight line. People are already sitting at some tables. The tables are numbered from 1 to n in the order from left to right. The state of the restauran... |
#include <bits/stdc++.h>
using namespace std;
int main() {
int xx = 0;
int t;
cin >> t;
while (t--) {
long long n, k, i;
string s;
cin >> n >> k >> s;
long long num = 0, d = k;
for (i = 0; i < n; i++) {
if (s[i] == '1') {
if (d < k) num--;
d = 0;
}
if (s[i] ... | ### Prompt
Develop a solution in CPP to the problem described below:
Polycarp and his friends want to visit a new restaurant. The restaurant has n tables arranged along a straight line. People are already sitting at some tables. The tables are numbered from 1 to n in the order from left to right. The state of the res... |
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
int n, k;
cin >> n >> k;
string s;
cin >> s;
vector<int> v;
v.push_back(-k - 1);
for (int i = 0; i < n; i++) {
if (s[i] == '1') {
v.push_back(i);
}
}
v.push_back(n + k)... | ### Prompt
Generate a cpp solution to the following problem:
Polycarp and his friends want to visit a new restaurant. The restaurant has n tables arranged along a straight line. People are already sitting at some tables. The tables are numbered from 1 to n in the order from left to right. The state of the restaurant ... |
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
int n, k, counter = 0, ans = 0;
bool firstonefounded = false;
string s;
cin >> n >> k;
cin >> s;
for (int i = 0; i < n; i++) {
if (s[i] == '0') {
counter++;
} else {
if (fi... | ### Prompt
Create a solution in Cpp for the following problem:
Polycarp and his friends want to visit a new restaurant. The restaurant has n tables arranged along a straight line. People are already sitting at some tables. The tables are numbered from 1 to n in the order from left to right. The state of the restauran... |
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5, MOD = 998244353;
int t, n, k, idx[N];
string s;
int main() {
cin >> t;
while (t--) {
cin >> n >> k >> s;
memset(idx, 0, sizeof(idx));
int l = 0, r = 0, ans = 0;
for (int i = 0; i < n; i++) {
if (s[i] == '1') {
idx[i] ... | ### Prompt
Construct a Cpp code solution to the problem outlined:
Polycarp and his friends want to visit a new restaurant. The restaurant has n tables arranged along a straight line. People are already sitting at some tables. The tables are numbered from 1 to n in the order from left to right. The state of the restau... |
#include <bits/stdc++.h>
using namespace std;
int main(void) {
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int T;
cin >> T;
cin.get();
while (T--) {
int n, k;
cin >> n >> k;
cin.get();
string s;
getline(cin, s);
int check = 0;
int cnt = 0;
int ans = 0;
f... | ### Prompt
Generate a cpp solution to the following problem:
Polycarp and his friends want to visit a new restaurant. The restaurant has n tables arranged along a straight line. People are already sitting at some tables. The tables are numbered from 1 to n in the order from left to right. The state of the restaurant ... |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
int t;
cin >> t;
while (t--) {
int k, n;
cin >> n >> k;
string s;
cin >> s;
int p = 0;
int cnt = 0;
bool flag;
while (p < n) {
flag = true;
for (int... | ### Prompt
Please create a solution in cpp to the following problem:
Polycarp and his friends want to visit a new restaurant. The restaurant has n tables arranged along a straight line. People are already sitting at some tables. The tables are numbered from 1 to n in the order from left to right. The state of the res... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.