output
stringlengths
52
181k
instruction
stringlengths
296
182k
#include<bits/stdc++.h> using namespace std; #define LL long long const LL mod=1e9+7,p=2,N=2e6; LL T,n,k; LL poww[32],pre[N],num[N],vis[N]; char s[N]; LL hashp(LL l,LL r) { return (pre[r]-pre[l-1]*poww[r-l+1]%mod+mod)%mod; } void init() { poww[0]=1; for(int i=1; i<=27; i++) poww[i]=poww[i-1]<<1; } int main...
### Prompt Develop a solution in Cpp to the problem described below: Let's call two strings a and b (both of length k) a bit similar if they have the same character in some position, i. e. there exists at least one i ∈ [1, k] such that a_i = b_i. You are given a binary string s of length n (a string of n characters ...
#include <bits/stdc++.h> using namespace std; typedef pair < int, int > pii; #define pb push_back #define khan ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); const int N = 2e6 + 5, mod = 1e9 + 7, INF = 1e9 + 7; const double eps = 100000; typedef long long ll; const ll BIG = 1e18; const int p1 = 29, p2 ...
### Prompt In CPP, your task is to solve the following problem: Let's call two strings a and b (both of length k) a bit similar if they have the same character in some position, i. e. there exists at least one i ∈ [1, k] such that a_i = b_i. You are given a binary string s of length n (a string of n characters 0 and...
#include<bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while(t--) { int n , k; cin >> n >> k; string x; cin >> x; int pr[n+1]; memset(pr ,0 , sizeof(pr)); for(int i = 0 ; i < n ; i++) { if(x[i] == '1') ...
### Prompt Construct a CPP code solution to the problem outlined: Let's call two strings a and b (both of length k) a bit similar if they have the same character in some position, i. e. there exists at least one i ∈ [1, k] such that a_i = b_i. You are given a binary string s of length n (a string of n characters 0 a...
#include <bits/stdc++.h> using namespace std; #define rep(i,a,b) for(int i=(a),i##end=(b);i<=i##end;++i) #define per(i,a,b) for(int i=(a),i##end=(b);i>=i##end;--i) mt19937 Rnd(chrono::high_resolution_clock::now().time_since_epoch().count()); template<typename T>void chkmax(T&x,T y){if(x<y)x=y;} template<typename T>voi...
### Prompt Please create a solution in CPP to the following problem: Let's call two strings a and b (both of length k) a bit similar if they have the same character in some position, i. e. there exists at least one i ∈ [1, k] such that a_i = b_i. You are given a binary string s of length n (a string of n characters ...
#include <bits/stdc++.h> using namespace std; #define FOR(a,b) for (int a=0; a<b; a++) #define FUR(a,b) for (int a=1; a<=b; a++) #define ROF(a,b) for (int a=b; a-->0; ) #define RUF(a,b) for (int a=b; a>0; a--) #define FORR(a,b,c) for (int a=b; a<c; a++) #define all(v) begin(v),end(v) #define rall(v) rbegin(v),rend(v) ...
### Prompt Create a solution in Cpp for the following problem: Let's call two strings a and b (both of length k) a bit similar if they have the same character in some position, i. e. there exists at least one i ∈ [1, k] such that a_i = b_i. You are given a binary string s of length n (a string of n characters 0 and/...
#include <bits/stdc++.h> typedef long long ll; using namespace std; char str[1001000]; pair<bool, int> check[(1<<23)]; int suf[1001000]; int dp[1001000]; int main(){ int t; scanf("%d", &t); while(t--){ int n, k; scanf("%d %d", &n, &k); scanf("%s", str); suf[0]=str[0]-'0'; ...
### Prompt Please provide a cpp coded solution to the problem described below: Let's call two strings a and b (both of length k) a bit similar if they have the same character in some position, i. e. there exists at least one i ∈ [1, k] such that a_i = b_i. You are given a binary string s of length n (a string of n c...
#include <bits/stdc++.h> using namespace std; using ll = long long; const int N = 2e6 + 10; char s[N]; int a[N]; char t[N]; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); int T; cin >> T; while (T--) { int n, k; cin >> n >> k; cin >> s; ...
### Prompt Your challenge is to write a Cpp solution to the following problem: Let's call two strings a and b (both of length k) a bit similar if they have the same character in some position, i. e. there exists at least one i ∈ [1, k] such that a_i = b_i. You are given a binary string s of length n (a string of n c...
/* _|_| _| _| _| _| _| _| _|_| _|_|_|_| _| _| _| _| _| _|_| _| _| _|_| _| _| _| _| _| _| _| _| _|_| _| _|_|_|_| _|_| _| _| ...
### Prompt Please formulate a CPP solution to the following problem: Let's call two strings a and b (both of length k) a bit similar if they have the same character in some position, i. e. there exists at least one i ∈ [1, k] such that a_i = b_i. You are given a binary string s of length n (a string of n characters ...