output stringlengths 52 181k | instruction stringlengths 296 182k |
|---|---|
#include <bits/stdc++.h>
using namespace std;
int32_t main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
long long n, m, q;
cin >> n >> m >> q;
string s, t;
cin >> s >> t;
vector<long long> matchingId;
for (long long i = 0; i <= n - m; i++) {
string second = s.substr(i, m);
if (second == t)... | ### Prompt
Your challenge is to write a CPP solution to the following problem:
You are given two strings s and t, both consisting only of lowercase Latin letters.
The substring s[l..r] is the string which is obtained by taking characters s_l, s_{l + 1}, ..., s_r without changing the order.
Each of the occurrences o... |
#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
long long int n, m, q;
cin >> n >> m >> q;
string s1, s2;
cin >> s1 >> s2;
long long int arr[n], d = 0;
for (long long int i = 0; i <= n - m; i++) {
string s3 = s1.... | ### Prompt
Please provide a Cpp coded solution to the problem described below:
You are given two strings s and t, both consisting only of lowercase Latin letters.
The substring s[l..r] is the string which is obtained by taking characters s_l, s_{l + 1}, ..., s_r without changing the order.
Each of the occurrences o... |
#include <bits/stdc++.h>
using namespace std;
int main() {
vector<int> left, right;
int n, m, s, l, r;
string kata, q;
cin >> n >> m >> s;
cin >> kata >> q;
size_t pos = kata.find(q, 0);
while (pos != string::npos) {
left.push_back(pos + 1);
right.push_back(pos + m);
pos = kata.find(q, pos + 1... | ### Prompt
Generate a Cpp solution to the following problem:
You are given two strings s and t, both consisting only of lowercase Latin letters.
The substring s[l..r] is the string which is obtained by taking characters s_l, s_{l + 1}, ..., s_r without changing the order.
Each of the occurrences of string a in a st... |
#include <bits/stdc++.h>
using namespace std;
int a[10000];
int inds[10000];
int main() {
int n, m, q;
cin >> n >> m >> q;
string str, target;
cin >> str >> target;
for (int i = 0; i <= (n - m); i++) {
if (str[i] == target[0]) {
string temp = str.substr(i, m);
if (temp == target)
a[i] ... | ### Prompt
Please provide a cpp coded solution to the problem described below:
You are given two strings s and t, both consisting only of lowercase Latin letters.
The substring s[l..r] is the string which is obtained by taking characters s_l, s_{l + 1}, ..., s_r without changing the order.
Each of the occurrences o... |
#include <bits/stdc++.h>
using namespace std;
void urmi() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
}
int main() {
long long n, m, q, i, c = 0, d = 0, e, f;
cin >> n >> m >> q;
string s, t;
cin >> s >> t;
map<long long, long long> m1;
for (i = 0; i < n; i++) {
if (s.compar... | ### Prompt
Please create a solution in cpp to the following problem:
You are given two strings s and t, both consisting only of lowercase Latin letters.
The substring s[l..r] is the string which is obtained by taking characters s_l, s_{l + 1}, ..., s_r without changing the order.
Each of the occurrences of string a... |
#include <bits/stdc++.h>
using namespace std;
int pre[1005], p, n, m, t, l, r;
char a[1005], b[1005];
int main() {
cin >> n >> m >> t;
cin >> (a + 1) >> b;
for (int i = 1; i <= n - m + 1; i++) {
p = 0;
for (int j = 0; j < m; j++) {
if (a[i + j] != b[j]) {
p = 1;
break;
}
}
... | ### Prompt
Your task is to create a cpp solution to the following problem:
You are given two strings s and t, both consisting only of lowercase Latin letters.
The substring s[l..r] is the string which is obtained by taking characters s_l, s_{l + 1}, ..., s_r without changing the order.
Each of the occurrences of st... |
#include <bits/stdc++.h>
using namespace std;
string str, sub;
vector<long long int> v;
int main() {
long long int n, m, q, x, y;
cin >> n >> m >> q;
cin >> str >> sub;
size_t pos = str.find(sub, 0);
while (pos != string::npos) {
v.push_back(pos);
pos = str.find(sub, pos + 1);
}
while (q--) {
... | ### Prompt
Generate a Cpp solution to the following problem:
You are given two strings s and t, both consisting only of lowercase Latin letters.
The substring s[l..r] is the string which is obtained by taking characters s_l, s_{l + 1}, ..., s_r without changing the order.
Each of the occurrences of string a in a st... |
#include <bits/stdc++.h>
using namespace std;
int a[1005];
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
int n, m, q;
cin >> n >> m >> q;
string s, t;
cin >> s >> t;
for (int i = 0; i + m <= n; ++i) {
if (s.substr(i, m) == t) {
a[i + 1]++;
}
}
for (int i = 1; i <= n; ++i) a[i] += a[i... | ### Prompt
Develop a solution in cpp to the problem described below:
You are given two strings s and t, both consisting only of lowercase Latin letters.
The substring s[l..r] is the string which is obtained by taking characters s_l, s_{l + 1}, ..., s_r without changing the order.
Each of the occurrences of string a... |
#include <bits/stdc++.h>
using namespace std;
;
const double eps = 1e-8;
const int mod = 10007;
const int maxn = 1e6 + 7;
const double pi = acos(-1);
const int inf = 0x3f3f3f3f;
const long long INF = 0x3f3f3f3f3f3f3f;
const unsigned long long p = 2333;
int n, m, q, l, r, ans;
unsigned long long hs[1007], ht, pw[1007];
... | ### Prompt
Generate a CPP solution to the following problem:
You are given two strings s and t, both consisting only of lowercase Latin letters.
The substring s[l..r] is the string which is obtained by taking characters s_l, s_{l + 1}, ..., s_r without changing the order.
Each of the occurrences of string a in a st... |
#include <bits/stdc++.h>
int a, b, c, i, j, ch, x, y, S[1004];
char s[1004], w[1004];
int main() {
scanf("%d%d%d", &a, &b, &c);
scanf("%s%s", s, w);
for (i = 0; i + b - 1 < a; i++) {
ch = 0;
for (j = 0; j < b; j++) {
if (s[i + j] == w[j]) ch++;
}
if (ch == b) {
S[i + 1]++;
}
S[... | ### Prompt
Please provide a Cpp coded solution to the problem described below:
You are given two strings s and t, both consisting only of lowercase Latin letters.
The substring s[l..r] is the string which is obtained by taking characters s_l, s_{l + 1}, ..., s_r without changing the order.
Each of the occurrences o... |
#include <bits/stdc++.h>
using namespace std;
char a[1000010];
char b[1000010];
int f[1000010];
int n, m, t;
int main() {
cin >> n >> m >> t;
cin >> a + 1 >> b;
for (int i = 1; i <= n - m + 1; i++) {
bool mark = 1;
for (int j = 0; j < m; j++) {
if (a[i + j] != b[j]) {
mark = 0;
break... | ### Prompt
Your task is to create a Cpp solution to the following problem:
You are given two strings s and t, both consisting only of lowercase Latin letters.
The substring s[l..r] is the string which is obtained by taking characters s_l, s_{l + 1}, ..., s_r without changing the order.
Each of the occurrences of st... |
#include <bits/stdc++.h>
using namespace std;
int main() {
long long n, m, q;
scanf("%lld", &n), scanf("%lld", &m), scanf("%lld", &q);
string s, t;
cin >> s >> t;
long long cs[n + 10];
cs[0] = 0;
memset(cs, 0, sizeof cs);
for (long long i = 0; i < n; i++) {
bool f = true;
if (n < m) {
cs[i... | ### Prompt
Generate a Cpp solution to the following problem:
You are given two strings s and t, both consisting only of lowercase Latin letters.
The substring s[l..r] is the string which is obtained by taking characters s_l, s_{l + 1}, ..., s_r without changing the order.
Each of the occurrences of string a in a st... |
#include <bits/stdc++.h>
using namespace std;
int val[1005], rang[1005];
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
string s, t;
int n, m, q;
cin >> n >> m >> q;
cin >> s >> t;
for (int i = 0; i < s.size(); i++) {
int cnt = 0;
for (int j = 0; j < t.size(); j++) {
if (i + j >= s.s... | ### Prompt
Your challenge is to write a cpp solution to the following problem:
You are given two strings s and t, both consisting only of lowercase Latin letters.
The substring s[l..r] is the string which is obtained by taking characters s_l, s_{l + 1}, ..., s_r without changing the order.
Each of the occurrences o... |
#include <bits/stdc++.h>
using namespace std;
vector<int> z_function(string s) {
int n = (int)s.length();
vector<int> z(n);
for (int i = 1, l = 0, r = 0; i < n; ++i) {
if (i <= r) z[i] = min(r - i + 1, z[i - l]);
while (i + z[i] < n && s[z[i]] == s[i + z[i]]) ++z[i];
if (i + z[i] - 1 > r) {
l = ... | ### Prompt
Construct a Cpp code solution to the problem outlined:
You are given two strings s and t, both consisting only of lowercase Latin letters.
The substring s[l..r] is the string which is obtained by taking characters s_l, s_{l + 1}, ..., s_r without changing the order.
Each of the occurrences of string a in... |
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, m, q;
cin >> n >> m >> q;
string s, t;
cin >> s >> t;
vector<int> amijanina;
for (int i = 0; i < s.size(); i++) {
bool iloveuazrin = true;
for (int j = 0; j < t.size(); j++) {
if (s[i + j] != t[j]) {
iloveuazrin = false;... | ### Prompt
Please formulate a CPP solution to the following problem:
You are given two strings s and t, both consisting only of lowercase Latin letters.
The substring s[l..r] is the string which is obtained by taking characters s_l, s_{l + 1}, ..., s_r without changing the order.
Each of the occurrences of string a... |
#include <bits/stdc++.h>
using namespace std;
int n, m, q;
string s, t;
int a[1024];
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cin >> n >> m >> q;
cin >> s >> t;
for (int i = 0; i <= n - m; i++) {
a[i] = 1;
for (int j = 0; j < m; j++) {
if (s[i + j] != t[j]) {
a[i] = 0;... | ### Prompt
Your task is to create a Cpp solution to the following problem:
You are given two strings s and t, both consisting only of lowercase Latin letters.
The substring s[l..r] is the string which is obtained by taking characters s_l, s_{l + 1}, ..., s_r without changing the order.
Each of the occurrences of st... |
#include <bits/stdc++.h>
using namespace std;
const int N = 1e3 + 5;
int n, m, q, dp[N][N], p[N + N], used[N + N];
string s, t;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> n >> m >> q >> s >> t;
string x = t + "#" + s;
for (int i = 1; i < (int)x.size(); i++) {
int j = p[i ... | ### Prompt
Please formulate a cpp solution to the following problem:
You are given two strings s and t, both consisting only of lowercase Latin letters.
The substring s[l..r] is the string which is obtained by taking characters s_l, s_{l + 1}, ..., s_r without changing the order.
Each of the occurrences of string a... |
#include <bits/stdc++.h>
using namespace std;
const long long MX = 1e3 + 100, INF = 1e17, INF2 = -1e18, D = 1e9 + 7;
long long par[MX];
int32_t main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
long long n, m, q;
cin >> n >> m >> q;
string s, t;
cin >> s >> t;
for (long long i = n - m; i >= 0; ... | ### Prompt
Please formulate a CPP solution to the following problem:
You are given two strings s and t, both consisting only of lowercase Latin letters.
The substring s[l..r] is the string which is obtained by taking characters s_l, s_{l + 1}, ..., s_r without changing the order.
Each of the occurrences of string a... |
#include <bits/stdc++.h>
using namespace std;
char s[1005], t[1005];
int n, m, q;
int c[1005];
int main() {
scanf("%d%d%d", &n, &m, &q);
scanf("%s", s + 1);
scanf("%s", t + 1);
for (int i = 1; i <= n; i++) {
c[i] = c[i - 1];
int d = 1;
for (int j = 1; j <= m; j++) {
if (s[i + j - 1] != t[j]) d... | ### Prompt
Please provide a CPP coded solution to the problem described below:
You are given two strings s and t, both consisting only of lowercase Latin letters.
The substring s[l..r] is the string which is obtained by taking characters s_l, s_{l + 1}, ..., s_r without changing the order.
Each of the occurrences o... |
#include <bits/stdc++.h>
const double PI = acos(-1.0);
using namespace std;
int setb(int n, int pos) { return n = n | (1 << pos); }
int resb(int n, int pos) { return n = n & ~(1 << pos); }
bool checkb(long long n, long long pos) { return (bool)(n & (1ll << pos)); }
long long bigmod(long long b, long long p, long long m... | ### Prompt
Your task is to create a cpp solution to the following problem:
You are given two strings s and t, both consisting only of lowercase Latin letters.
The substring s[l..r] is the string which is obtained by taking characters s_l, s_{l + 1}, ..., s_r without changing the order.
Each of the occurrences of st... |
#include <bits/stdc++.h>
using namespace std;
long long n, m, f[200000], d[200000], i, j, l, r, q, edd;
string s, t;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> n >> m >> q;
cin >> s >> t;
for (i = 0; i < n; i++) {
if (s[i] == t[0] && i + m <= n) {
edd = 1;
for... | ### Prompt
Create a solution in cpp for the following problem:
You are given two strings s and t, both consisting only of lowercase Latin letters.
The substring s[l..r] is the string which is obtained by taking characters s_l, s_{l + 1}, ..., s_r without changing the order.
Each of the occurrences of string a in a ... |
#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 7;
const int M = 1e5 + 7;
const long double pi = 3.1415926535897;
int n, m, q, l, r, cnt[N];
string s, t;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> n >> m >> q;
cin >> s;
cin >> t;
s = ' ' + s;
t = ' ' + t... | ### Prompt
Develop a solution in cpp to the problem described below:
You are given two strings s and t, both consisting only of lowercase Latin letters.
The substring s[l..r] is the string which is obtained by taking characters s_l, s_{l + 1}, ..., s_r without changing the order.
Each of the occurrences of string a... |
#include <bits/stdc++.h>
#pragma GCC optimize "Ofast"
#pragma GCC optimize "unroll-loops"
#pragma GCC target "sse,sse2,sse3,sse4,abm,avx,mmx,popcnt,tune=native"
char _;
using namespace std;
string a, b;
int n, m, q, c, d;
int PSA[3010];
int main() {
cin.sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> n >> m... | ### Prompt
Please formulate a Cpp solution to the following problem:
You are given two strings s and t, both consisting only of lowercase Latin letters.
The substring s[l..r] is the string which is obtained by taking characters s_l, s_{l + 1}, ..., s_r without changing the order.
Each of the occurrences of string a... |
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
long long n, m, q, i, j;
cin >> n >> m >> q;
string a, b;
cin >> a >> b;
vector<long long> v(n + 1);
for (i = 0; i <= n - m; i++) {
string tmp = a.substr(i, m);
if (tmp == b) v[i +... | ### Prompt
Generate a Cpp solution to the following problem:
You are given two strings s and t, both consisting only of lowercase Latin letters.
The substring s[l..r] is the string which is obtained by taking characters s_l, s_{l + 1}, ..., s_r without changing the order.
Each of the occurrences of string a in a st... |
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
;
long long int n, m, q;
cin >> n >> m >> q;
string s, t;
cin >> s >> t;
long long int l, r;
long long int cnt;
long long int ans[10005] = {0};
for (long long int i = 0; i < (n - m + 1); i++) {... | ### Prompt
Create a solution in Cpp for the following problem:
You are given two strings s and t, both consisting only of lowercase Latin letters.
The substring s[l..r] is the string which is obtained by taking characters s_l, s_{l + 1}, ..., s_r without changing the order.
Each of the occurrences of string a in a ... |
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
int n, m, q;
cin >> n >> m >> q;
int cnt[n + 1];
string s, s1;
cin >> s >> s1;
s = "1" + s;
int k = s.find(s1);
if (k == string::npos)
fill(cnt, cnt + n, 0);
else {
fill(cnt, cnt + k, 0);
cnt[k] = 1;
... | ### Prompt
Please create a solution in CPP to the following problem:
You are given two strings s and t, both consisting only of lowercase Latin letters.
The substring s[l..r] is the string which is obtained by taking characters s_l, s_{l + 1}, ..., s_r without changing the order.
Each of the occurrences of string a... |
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, m, q;
cin >> n >> m >> q;
string s1, s2;
cin >> s1 >> s2;
vector<pair<int, int> > p;
int ans = 1;
for (int i = 0; i < n; i++) {
if (s1[i] == s2[0]) {
for (int k = 1; k < m && i + k < n; k++) {
if (s1[i + k] == s2[k]) ans++... | ### Prompt
Construct a CPP code solution to the problem outlined:
You are given two strings s and t, both consisting only of lowercase Latin letters.
The substring s[l..r] is the string which is obtained by taking characters s_l, s_{l + 1}, ..., s_r without changing the order.
Each of the occurrences of string a in... |
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e3;
char s[MAXN];
char t[MAXN];
int Begin[MAXN];
int main() {
int n, m, q;
int ans;
int i, j;
int l, r;
cin >> n >> m >> q;
cin >> s + 1;
cin >> t + 1;
for (i = 1; i + m - 1 <= n; i++) {
for (j = 1; j <= m; j++) {
if (s[i + j - 1]... | ### Prompt
Develop a solution in Cpp to the problem described below:
You are given two strings s and t, both consisting only of lowercase Latin letters.
The substring s[l..r] is the string which is obtained by taking characters s_l, s_{l + 1}, ..., s_r without changing the order.
Each of the occurrences of string a... |
#include <bits/stdc++.h>
using namespace std;
int n, m, q;
int i, j;
char s[1005];
char t[1005];
int nx[1005];
int ck[1005];
int main() {
scanf("%d%d%d", &n, &m, &q);
scanf("%s", s + 1);
scanf("%s", t + 1);
for (i = 2; i <= m; i++) {
while (j && t[j + 1] != t[i]) j = nx[j];
if (t[j + 1] == t[i]) j++;
... | ### Prompt
Construct a cpp code solution to the problem outlined:
You are given two strings s and t, both consisting only of lowercase Latin letters.
The substring s[l..r] is the string which is obtained by taking characters s_l, s_{l + 1}, ..., s_r without changing the order.
Each of the occurrences of string a in... |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
template <class T>
using V = vector<T>;
template <class T>
using VV = V<V<T> >;
const int maxn = (int)1e5 + 5;
const int inf = (int)1e9 + 7;
const ll linf = (ll)1e18 + 7;
const ld pi = acosl(-1.0);
const ld eps = 1e-9;
void S() ... | ### Prompt
Your task is to create a cpp solution to the following problem:
You are given two strings s and t, both consisting only of lowercase Latin letters.
The substring s[l..r] is the string which is obtained by taking characters s_l, s_{l + 1}, ..., s_r without changing the order.
Each of the occurrences of st... |
#include <bits/stdc++.h>
using namespace std;
char s1[(20ll + (long long int)1e3)];
char s2[(20ll + (long long int)1e3)];
long long int xds[(20ll + (long long int)1e3) << 2];
long long int eds[(20ll + (long long int)1e3) << 2];
long long int n, m;
long long int pushup(long long int cur) {
return xds[cur] = xds[cur <<... | ### Prompt
Your task is to create a Cpp solution to the following problem:
You are given two strings s and t, both consisting only of lowercase Latin letters.
The substring s[l..r] is the string which is obtained by taking characters s_l, s_{l + 1}, ..., s_r without changing the order.
Each of the occurrences of st... |
#include <bits/stdc++.h>
#pragma warning(disable : 4996)
using namespace std;
int main() {
int n, m, q;
scanf("%d %d %d", &n, &m, &q);
string a, b;
cin >> a >> b;
int ps[1007] = {0};
for (int i = 1; i <= n; i++) {
if (i < m) continue;
bool flag = false;
for (int j = i - m; j < i; j++)
if (... | ### Prompt
In cpp, your task is to solve the following problem:
You are given two strings s and t, both consisting only of lowercase Latin letters.
The substring s[l..r] is the string which is obtained by taking characters s_l, s_{l + 1}, ..., s_r without changing the order.
Each of the occurrences of string a in a... |
#include <bits/stdc++.h>
using namespace std;
int n, m, q, arr[1001], l, r;
string s, t;
int main() {
cin >> n >> m >> q;
cin >> s >> t;
for (int i = 0; i <= n - m; i++) {
arr[i + 1] = arr[i];
if (s.substr(i, m) == t) {
arr[i + 1]++;
}
}
for (int j = 1; j <= q; j++) {
cin >> l >> r;
... | ### Prompt
Please formulate a cpp solution to the following problem:
You are given two strings s and t, both consisting only of lowercase Latin letters.
The substring s[l..r] is the string which is obtained by taking characters s_l, s_{l + 1}, ..., s_r without changing the order.
Each of the occurrences of string a... |
#include <bits/stdc++.h>
using namespace std;
const int MX = 1e3 + 10, MD = 1e9 + 7;
long long n, m, a[MX], ans, tmp, ps[MX], ps2[MX], q;
string s, t, k;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cin >> n >> m >> q;
cin >> s >> t;
int flag = 0;
for (int i = 0; i < n; i++) {
ps[i + 1] += ps[i];
... | ### Prompt
Create a solution in CPP for the following problem:
You are given two strings s and t, both consisting only of lowercase Latin letters.
The substring s[l..r] is the string which is obtained by taking characters s_l, s_{l + 1}, ..., s_r without changing the order.
Each of the occurrences of string a in a ... |
#include <bits/stdc++.h>
using namespace std;
int kmp(string T, string &P) {
if (P.empty()) return 0;
if (T.size() < P.size()) return 0;
vector<int> prefix(P.size(), 0);
for (int i = 1, k = 0; i < P.size(); ++i) {
while (k && P[k] != P[i]) k = prefix[k - 1];
if (P[k] == P[i]) ++k;
prefix[i] = k;
}... | ### Prompt
Please create a solution in CPP to the following problem:
You are given two strings s and t, both consisting only of lowercase Latin letters.
The substring s[l..r] is the string which is obtained by taking characters s_l, s_{l + 1}, ..., s_r without changing the order.
Each of the occurrences of string a... |
#include <bits/stdc++.h>
using namespace std;
int N, M, Q;
char S[1001], T[1001];
int A[1001], P[1001];
void f() {
for (int i = 0; i + M <= N; i++) {
int ok = 1;
for (int j = 0; j < M && ok; j++) ok = (S[i + j] == T[j]);
A[i] = ok;
}
}
int main(int argc, char **argv) {
ios::sync_with_stdio(false);
c... | ### Prompt
Develop a solution in Cpp to the problem described below:
You are given two strings s and t, both consisting only of lowercase Latin letters.
The substring s[l..r] is the string which is obtained by taking characters s_l, s_{l + 1}, ..., s_r without changing the order.
Each of the occurrences of string a... |
#include <bits/stdc++.h>
using namespace std;
char a[1005];
char b[1005];
int t[1005];
int sum[1005];
int main() {
memset(t, 0, sizeof(t));
int p, n, m;
cin >> n >> m >> p;
cin >> a >> b;
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
if (a[i + j] != b[j])
break;
else if (... | ### Prompt
Create a solution in CPP for the following problem:
You are given two strings s and t, both consisting only of lowercase Latin letters.
The substring s[l..r] is the string which is obtained by taking characters s_l, s_{l + 1}, ..., s_r without changing the order.
Each of the occurrences of string a in a ... |
#include <bits/stdc++.h>
using namespace std;
int n, m, q;
const int maxn = 1005;
char s[maxn], t[maxn];
int sum[maxn];
int main() {
scanf("%d%d%d", &n, &m, &q);
scanf("%s", s + 1);
scanf("%s", t + 1);
for (int i = 1; i <= n - m + 1; i++) {
bool f = 1;
for (int j = 1; j <= m; j++)
if (s[i + j - 1]... | ### Prompt
Develop a solution in Cpp to the problem described below:
You are given two strings s and t, both consisting only of lowercase Latin letters.
The substring s[l..r] is the string which is obtained by taking characters s_l, s_{l + 1}, ..., s_r without changing the order.
Each of the occurrences of string a... |
#include <bits/stdc++.h>
int n, m, q, nxt[1005], a[1005], b[1005], cnt;
char s[1005], t[1005];
inline void getnxt() {
nxt[0] = -1;
for (register int i = 1, tmp; i < m; i++) {
tmp = nxt[i - 1];
while (tmp >= 0 && t[tmp + 1] != t[i]) tmp = nxt[tmp];
if (t[tmp + 1] == t[i])
nxt[i] = tmp + 1;
else... | ### Prompt
In cpp, your task is to solve the following problem:
You are given two strings s and t, both consisting only of lowercase Latin letters.
The substring s[l..r] is the string which is obtained by taking characters s_l, s_{l + 1}, ..., s_r without changing the order.
Each of the occurrences of string a in a... |
#include <bits/stdc++.h>
using namespace std;
const int N = 1e3 + 7;
const int mod = 1e9 + 7;
char str[N];
char s[N];
int a[1000 + 7];
int main() {
int n, m, q;
scanf("%d%d%d", &n, &m, &q);
scanf("%s", str + 1);
scanf("%s", s + 1);
int ans = 0;
for (int i = 1; i <= n; i++) {
int cnt = 1;
while (str[... | ### Prompt
In cpp, your task is to solve the following problem:
You are given two strings s and t, both consisting only of lowercase Latin letters.
The substring s[l..r] is the string which is obtained by taking characters s_l, s_{l + 1}, ..., s_r without changing the order.
Each of the occurrences of string a in a... |
#include <bits/stdc++.h>
using namespace std;
const long long N = 1e5 + 2;
const long long N1 = 1e2 + 2;
const long long mod = 1e9 + 7;
const int MASK = 1 << 17 + 1;
const int who = 6 * N * log2(N);
int a[N + 1];
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n, m, q;
cin >> n >> m >> q;
st... | ### Prompt
Please create a solution in cpp to the following problem:
You are given two strings s and t, both consisting only of lowercase Latin letters.
The substring s[l..r] is the string which is obtained by taking characters s_l, s_{l + 1}, ..., s_r without changing the order.
Each of the occurrences of string a... |
#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
char a[1005];
char b[1005];
int t[1005];
int sum[1005];
int main() {
memset(t, 0, sizeof(t));
int p, n, m;
cin >> n >> m >> p;
cin >> a >> b;
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
if (a[i + j] != b[j])
... | ### Prompt
Please formulate a cpp solution to the following problem:
You are given two strings s and t, both consisting only of lowercase Latin letters.
The substring s[l..r] is the string which is obtained by taking characters s_l, s_{l + 1}, ..., s_r without changing the order.
Each of the occurrences of string a... |
#include <bits/stdc++.h>
using namespace std;
const int base = 317;
const int mod1 = 1e9 + 2277;
const int mod2 = 1e9 + 5277;
const int N = 1e3 + 5;
int n, m, q, dp[N][N];
string s, t;
pair<long long, long long> Hash_s[N], Hash_t[N], pw[N];
pair<long long, long long> get_hash_s(int l, int r) {
long long fi =
(H... | ### Prompt
Please create a solution in Cpp to the following problem:
You are given two strings s and t, both consisting only of lowercase Latin letters.
The substring s[l..r] is the string which is obtained by taking characters s_l, s_{l + 1}, ..., s_r without changing the order.
Each of the occurrences of string a... |
#include <bits/stdc++.h>
using namespace std;
const int mxN = 1e3 + 3;
bool cnt[mxN];
int sum[mxN];
int main() {
int n, m, a, i, j;
string s, ss;
cin >> n >> m >> a >> s >> ss;
for (i = 0; i < n - m + 1; i++) {
bool f = true;
for (j = 0; j < m; j++)
if (s[i + j] != ss[j]) {
f = false;
... | ### Prompt
Your task is to create a CPP solution to the following problem:
You are given two strings s and t, both consisting only of lowercase Latin letters.
The substring s[l..r] is the string which is obtained by taking characters s_l, s_{l + 1}, ..., s_r without changing the order.
Each of the occurrences of st... |
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, q, m, i, j;
int dp[1010][1010];
int dp2[1010];
for (i = 0; i < 1010; i++) {
for (j = 0; j < 1010; j++) dp[i][j] = 0;
}
cin >> n >> m >> q;
string str1, str2;
cin >> str1;
cin >> str2;
int flag, k;
for (i = 0; i < n; i++) {
f... | ### Prompt
Create a solution in Cpp for the following problem:
You are given two strings s and t, both consisting only of lowercase Latin letters.
The substring s[l..r] is the string which is obtained by taking characters s_l, s_{l + 1}, ..., s_r without changing the order.
Each of the occurrences of string a in a ... |
#include <bits/stdc++.h>
using namespace std;
long long n, m, l, r, ss[10000001], q, a[10000001];
string second, t;
int main() {
cin >> n >> m >> q;
cin >> second >> t;
for (int i = 0; i < second.size(); i++) {
string st = "";
for (int j = i; j < second.size(); j++) {
st += second[j];
if (st =... | ### Prompt
Please formulate a cpp solution to the following problem:
You are given two strings s and t, both consisting only of lowercase Latin letters.
The substring s[l..r] is the string which is obtained by taking characters s_l, s_{l + 1}, ..., s_r without changing the order.
Each of the occurrences of string a... |
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, m, q, l, r;
cin >> n >> m >> q;
string a, b;
cin >> a >> b;
bool p[n + 1];
for (int i = 0; i < n + 1; i++) {
bool f = true;
for (int j = 0; j < m; j++)
if (a[i + j] != b[j]) {
f = false;
break;
}
p[i + ... | ### Prompt
Please create a solution in CPP to the following problem:
You are given two strings s and t, both consisting only of lowercase Latin letters.
The substring s[l..r] is the string which is obtained by taking characters s_l, s_{l + 1}, ..., s_r without changing the order.
Each of the occurrences of string a... |
#include <bits/stdc++.h>
using namespace std;
char s[1005], t[1005];
int pre[1005], q, n, m, a, b, prel[1005];
int main() {
scanf("%d%d%d", &n, &m, &q);
scanf("%s%s", &s[1], &t[1]);
for (int i = 1; i <= n; ++i) {
int j = 1, temp = i;
while (temp <= n && j <= m && t[j] == s[temp]) {
j++, temp++;
... | ### Prompt
Construct a cpp code solution to the problem outlined:
You are given two strings s and t, both consisting only of lowercase Latin letters.
The substring s[l..r] is the string which is obtained by taking characters s_l, s_{l + 1}, ..., s_r without changing the order.
Each of the occurrences of string a in... |
#include <bits/stdc++.h>
int occ[10000];
using namespace std;
int main() {
int n, m, q;
int sol;
cin >> n >> m >> q;
string s1, s2;
cin >> s1 >> s2;
for (int i = 0; i < n; i++) {
bool test = true;
for (int j = 0; j < m; j++) {
if (s1[i + j] != s2[j]) {
test = false;
break;
... | ### Prompt
Your challenge is to write a CPP solution to the following problem:
You are given two strings s and t, both consisting only of lowercase Latin letters.
The substring s[l..r] is the string which is obtained by taking characters s_l, s_{l + 1}, ..., s_r without changing the order.
Each of the occurrences o... |
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, m, q, l, r, index = 0, c = 0;
string s, t;
cin >> n >> m >> q >> s >> t;
bool a[n];
for (int i = 0; i < n; i++) {
index = 0;
for (int j = i; j < i + m; j++) {
if (s[j] == t[index])
index++;
else
break;
}
... | ### Prompt
In CPP, your task is to solve the following problem:
You are given two strings s and t, both consisting only of lowercase Latin letters.
The substring s[l..r] is the string which is obtained by taking characters s_l, s_{l + 1}, ..., s_r without changing the order.
Each of the occurrences of string a in a... |
#include <bits/stdc++.h>
using namespace std;
long long const MOD = 1e9 + 7;
long long const N = 1e3 + 10;
long long ara[N + 1];
long long bra[N + 1];
int main() {
(ios_base::sync_with_stdio(false), cin.tie(NULL));
long long n, m, q;
cin >> n >> m >> q;
string str, s;
cin >> str >> s;
for (long long i = 0; ... | ### Prompt
Construct a cpp code solution to the problem outlined:
You are given two strings s and t, both consisting only of lowercase Latin letters.
The substring s[l..r] is the string which is obtained by taking characters s_l, s_{l + 1}, ..., s_r without changing the order.
Each of the occurrences of string a in... |
#include <bits/stdc++.h>
using namespace std;
char s1[1005], s2[1005];
int s1len, s2len;
int Next[1005];
void kmp() {
int i = 0;
Next[i] = -1;
int j = -1;
while (i < s1len) {
if (j == -1 || s1[i] == s1[j]) {
i++;
j++;
Next[i] = j;
} else {
j = Next[j];
}
}
}
int main(void) ... | ### Prompt
Your task is to create a CPP solution to the following problem:
You are given two strings s and t, both consisting only of lowercase Latin letters.
The substring s[l..r] is the string which is obtained by taking characters s_l, s_{l + 1}, ..., s_r without changing the order.
Each of the occurrences of st... |
#include <bits/stdc++.h>
using namespace std;
long long int countSetBits(long long int n) {
long long int count = 0;
while (n) {
n &= (n - 1);
count++;
}
return count;
}
long long int power(long long int x, long long int y) {
if (y == 0)
return 1;
else if (y % 2 == 0)
return power(x, y / 2) ... | ### Prompt
Please formulate a cpp solution to the following problem:
You are given two strings s and t, both consisting only of lowercase Latin letters.
The substring s[l..r] is the string which is obtained by taking characters s_l, s_{l + 1}, ..., s_r without changing the order.
Each of the occurrences of string a... |
#include <bits/stdc++.h>
using namespace std;
struct re {
int x, y, cs;
};
const long long module = 1000000000 + 7;
const int maxN = 1000 + 10;
int n, m, q, kq[maxN];
string s, t;
void nhap() { cin >> n >> m >> q >> s >> t; }
int kt(int x) {
for (int i = 1; i <= m - 1; ++i)
if (s[x + i] != t[i]) return (0);
r... | ### Prompt
Construct a Cpp code solution to the problem outlined:
You are given two strings s and t, both consisting only of lowercase Latin letters.
The substring s[l..r] is the string which is obtained by taking characters s_l, s_{l + 1}, ..., s_r without changing the order.
Each of the occurrences of string a in... |
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, m, t;
cin >> n >> m >> t;
string a, b;
cin >> a >> b;
int begin[n];
int cumm[n];
memset(begin, 0, sizeof(begin));
for (int i = 0; i <= n - m; i++) {
bool match = true;
for (int j = i; j < i + m; j++) {
if (b[j - i] != a[j]) ... | ### Prompt
Develop a solution in CPP to the problem described below:
You are given two strings s and t, both consisting only of lowercase Latin letters.
The substring s[l..r] is the string which is obtained by taking characters s_l, s_{l + 1}, ..., s_r without changing the order.
Each of the occurrences of string a... |
#include <bits/stdc++.h>
using namespace std;
vector<int> v;
int main() {
int n, m, q;
string s, t;
cin >> n >> m >> q;
cin >> s >> t;
for (int i = 0; i < n; i++) {
if (s.substr(i, m) == t)
v.push_back(1);
else
v.push_back(0);
}
while (q--) {
int left, right, ans = 0;
cin >> le... | ### Prompt
Create a solution in Cpp for the following problem:
You are given two strings s and t, both consisting only of lowercase Latin letters.
The substring s[l..r] is the string which is obtained by taking characters s_l, s_{l + 1}, ..., s_r without changing the order.
Each of the occurrences of string a in a ... |
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e3 + 5;
char s[maxn];
char t[maxn];
int ans[maxn];
int main() {
int n, m, q;
scanf("%d%d%d", &n, &m, &q);
int l, r;
int cnt = 0;
scanf("%s%s", s, t);
if (n < m) {
while (q--) {
printf("0\n");
}
return 0;
}
int flag;
for ... | ### Prompt
Develop a solution in CPP to the problem described below:
You are given two strings s and t, both consisting only of lowercase Latin letters.
The substring s[l..r] is the string which is obtained by taking characters s_l, s_{l + 1}, ..., s_r without changing the order.
Each of the occurrences of string a... |
#include <bits/stdc++.h>
using namespace std;
int main() {
long long n, m, q;
cin >> n >> m >> q;
string s;
cin >> s;
string r;
cin >> r;
long long lps[m];
lps[0] = 0;
long long len = 0;
long long i = 1;
while (i < m) {
if (r[i] == r[len]) {
len++;
lps[i] = len;
i++;
} el... | ### Prompt
Construct a cpp code solution to the problem outlined:
You are given two strings s and t, both consisting only of lowercase Latin letters.
The substring s[l..r] is the string which is obtained by taking characters s_l, s_{l + 1}, ..., s_r without changing the order.
Each of the occurrences of string a in... |
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n, m, q;
cin >> n >> m >> q;
string s, t;
cin >> s >> t;
vector<int> k(n, false);
for (int i = 0; i < n; ++i) {
bool flag = true;
for (int j = 0; j < m; ++j) {
if (i + j >= n || ... | ### Prompt
Please formulate a Cpp solution to the following problem:
You are given two strings s and t, both consisting only of lowercase Latin letters.
The substring s[l..r] is the string which is obtained by taking characters s_l, s_{l + 1}, ..., s_r without changing the order.
Each of the occurrences of string a... |
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, m, s;
string a, b;
int num[200005];
int t = 0;
cin >> n >> m >> s;
cin >> a >> b;
for (int i = 0; i < n; i++) {
int flag = 0;
for (int j = 0; j < m; j++) {
if (a[i + j] != b[j]) {
flag = 1;
break;
}
}... | ### Prompt
Please provide a cpp coded solution to the problem described below:
You are given two strings s and t, both consisting only of lowercase Latin letters.
The substring s[l..r] is the string which is obtained by taking characters s_l, s_{l + 1}, ..., s_r without changing the order.
Each of the occurrences o... |
#include <bits/stdc++.h>
using namespace std;
const long long M = 1000005;
int occur[1005];
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n, m, q;
string s, t;
cin >> n >> m >> q;
cin >> s >> t;
for (int i = 0; i < n - m + 1; i++) {
if (s.substr(i, m) == t) {
occur[i + 1] ... | ### Prompt
Your challenge is to write a Cpp solution to the following problem:
You are given two strings s and t, both consisting only of lowercase Latin letters.
The substring s[l..r] is the string which is obtained by taking characters s_l, s_{l + 1}, ..., s_r without changing the order.
Each of the occurrences o... |
#include <bits/stdc++.h>
int pi[1002];
void pi_function(char temp[], int len) {
int k = 0;
for (int q = 2; q < len + 1; q++) {
while (k > 0 && temp[k] != temp[q - 1]) k = pi[k];
if (temp[k] == temp[q - 1]) k++;
pi[q] = k;
}
return;
}
int main() {
int n, m, q;
scanf("%d%d%d", &n, &m, &q);
char ... | ### Prompt
In cpp, your task is to solve the following problem:
You are given two strings s and t, both consisting only of lowercase Latin letters.
The substring s[l..r] is the string which is obtained by taking characters s_l, s_{l + 1}, ..., s_r without changing the order.
Each of the occurrences of string a in a... |
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n, m, q;
cin >> n >> m >> q;
string s, t;
cin >> s >> t;
vector<int> v(n);
for (int i = 0; i <= n - m; i++) {
bool flag = 0;
for (int j = 0; j < m; j++) {
if (t[j] != s[i + j]) {... | ### Prompt
Please create a solution in Cpp to the following problem:
You are given two strings s and t, both consisting only of lowercase Latin letters.
The substring s[l..r] is the string which is obtained by taking characters s_l, s_{l + 1}, ..., s_r without changing the order.
Each of the occurrences of string a... |
#include <bits/stdc++.h>
using namespace std;
inline int read() {
char c = getchar();
int x = 0, f = 1;
for (; !isdigit(c); c = getchar())
if (c == '-') f = -1;
for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
return x * f;
}
const int MAXN = 1e5 + 5;
char s[MAXN], t[MAXN];
int nxt[MAXN], sum[MAXN]... | ### Prompt
Please provide a Cpp coded solution to the problem described below:
You are given two strings s and t, both consisting only of lowercase Latin letters.
The substring s[l..r] is the string which is obtained by taking characters s_l, s_{l + 1}, ..., s_r without changing the order.
Each of the occurrences o... |
#include <bits/stdc++.h>
using namespace std;
const int N = 1e3 + 9;
int n, m, q;
string s, t;
int a[N], b[N];
void check(int i) {
for (int j = 1; j <= m; ++j)
if (t[j] != s[j + i - 1]) return;
a[i + m - 1] = 1;
return;
}
int main() {
cin >> n >> m >> q;
cin >> s;
s = "#" + s;
cin >> t;
t = "@" + t;... | ### Prompt
Please provide a cpp coded solution to the problem described below:
You are given two strings s and t, both consisting only of lowercase Latin letters.
The substring s[l..r] is the string which is obtained by taking characters s_l, s_{l + 1}, ..., s_r without changing the order.
Each of the occurrences o... |
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, m, t;
cin >> n >> m >> t;
string a, b;
cin >> a >> b;
std::vector<int> v(n, 0);
int cnt = 0;
int p = 1, index = 0, flag = 0;
for (int i = 0; i <= n - m; ++i) v[i + 1] = v[i] + (a.substr(i, m) == b);
while (t--) {
int l, r;
cin >... | ### Prompt
Please provide a CPP coded solution to the problem described below:
You are given two strings s and t, both consisting only of lowercase Latin letters.
The substring s[l..r] is the string which is obtained by taking characters s_l, s_{l + 1}, ..., s_r without changing the order.
Each of the occurrences o... |
#include <bits/stdc++.h>
using namespace std;
vector<int> v[1003];
string text, pat;
vector<int> vv;
int main() {
int n, m, q;
cin >> n >> m >> q;
cin >> text >> pat;
for (int i = 0; i < n; i++) {
int x = 0;
for (int j = 0; j < m; j++) {
if ((j + i) < n && text[j + i] == pat[j]) {
x++;
... | ### Prompt
In CPP, your task is to solve the following problem:
You are given two strings s and t, both consisting only of lowercase Latin letters.
The substring s[l..r] is the string which is obtained by taking characters s_l, s_{l + 1}, ..., s_r without changing the order.
Each of the occurrences of string a in a... |
#include <bits/stdc++.h>
using namespace std;
string a, b;
int n, m, q;
int pos[1005];
int main() {
cin >> n >> m >> q;
cin >> a;
cin >> b;
for (int i = 0; i <= n - m; i++) {
if (a.substr(i, m) == b) {
pos[i] = 1;
}
}
while (q--) {
int x, y, ans = 0;
cin >> x >> y;
for (int i = x -... | ### Prompt
Develop a solution in CPP to the problem described below:
You are given two strings s and t, both consisting only of lowercase Latin letters.
The substring s[l..r] is the string which is obtained by taking characters s_l, s_{l + 1}, ..., s_r without changing the order.
Each of the occurrences of string a... |
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e3 + 10;
int n, m, q, l, r, pr[maxn];
bool ok[maxn], flag;
string s, t;
int main() {
cin >> n >> m >> q;
cin >> s >> t;
pr[0] = 0;
for (int i = 0; i < n - m + 1; i++) {
flag = true;
for (int j = 0; j < m; j++)
if (s[i + j] != t[j]) {
... | ### Prompt
In CPP, your task is to solve the following problem:
You are given two strings s and t, both consisting only of lowercase Latin letters.
The substring s[l..r] is the string which is obtained by taking characters s_l, s_{l + 1}, ..., s_r without changing the order.
Each of the occurrences of string a in a... |
#include <bits/stdc++.h>
using namespace std;
int n, m, q;
string str1, str2;
int ans[1005];
int main() {
scanf("%d %d %d", &n, &m, &q);
cin >> str1 >> str2;
int f[1005];
str1 = " " + str1;
str2 = " " + str2;
for (int i = 1; i <= n - m + 1; i++) {
f[i] = 1;
for (int j = 0; j < m; j++) {
if (st... | ### Prompt
Please provide a Cpp coded solution to the problem described below:
You are given two strings s and t, both consisting only of lowercase Latin letters.
The substring s[l..r] is the string which is obtained by taking characters s_l, s_{l + 1}, ..., s_r without changing the order.
Each of the occurrences o... |
#include <bits/stdc++.h>
using namespace std;
const int desll[4][2] = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}};
const long long mod = 1e9 + 7;
const int maxn = 1e6 + 7;
const int maxm = 1e8 + 7;
const double eps = 1e-4;
int m, n;
int ar[maxn];
char ch1[maxn], ch2[maxn];
int main() {
scanf("%d", &n);
scanf("%d", &m);
in... | ### Prompt
Generate a cpp solution to the following problem:
You are given two strings s and t, both consisting only of lowercase Latin letters.
The substring s[l..r] is the string which is obtained by taking characters s_l, s_{l + 1}, ..., s_r without changing the order.
Each of the occurrences of string a in a st... |
#include <bits/stdc++.h>
const double EPS = 0.00000001;
const long long mod = 1000000000 + 7;
using namespace std;
string s, t;
int a[2000], sum[2000];
int main() {
cout.sync_with_stdio(0);
int n, m, q;
cin >> n >> m >> q >> s >> t;
for (int i = 0; i < n; i++) {
int is = 1;
for (int j = 0; j < m; j++) {... | ### Prompt
Please provide a CPP coded solution to the problem described below:
You are given two strings s and t, both consisting only of lowercase Latin letters.
The substring s[l..r] is the string which is obtained by taking characters s_l, s_{l + 1}, ..., s_r without changing the order.
Each of the occurrences o... |
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e3 + 10;
char s1[maxn], s2[maxn];
int nxt[maxn];
int n, m, q;
void getFail(char *P, int *f) {
f[0] = 0;
f[1] = 0;
for (int i = 1; i < m; i++) {
int j = f[i];
while (j && P[i] != P[j]) j = f[j];
f[i + 1] = P[i] == P[j] ? j + 1 : 0;
}
}
i... | ### Prompt
Create a solution in cpp for the following problem:
You are given two strings s and t, both consisting only of lowercase Latin letters.
The substring s[l..r] is the string which is obtained by taking characters s_l, s_{l + 1}, ..., s_r without changing the order.
Each of the occurrences of string a in a ... |
#include <bits/stdc++.h>
using namespace std;
string st, subSt;
int lenSt, lenSubSt, queries;
vector<int> positions;
int main() {
ios::sync_with_stdio(0);
cin >> lenSt >> lenSubSt >> queries;
cin >> st;
cin >> subSt;
bool found;
for (int i = 0; i < lenSt - (lenSubSt - 1); i++) {
found = true;
for (i... | ### Prompt
Please provide a Cpp coded solution to the problem described below:
You are given two strings s and t, both consisting only of lowercase Latin letters.
The substring s[l..r] is the string which is obtained by taking characters s_l, s_{l + 1}, ..., s_r without changing the order.
Each of the occurrences o... |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int match[1000 + 1];
int psum[1000 + 1];
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n, m, q;
cin >> n >> m >> q;
string s, t;
cin >> s >> t;
memset(match, false, sizeof match);
for (int i = 0; i + m - 1 < n; i++) ... | ### Prompt
Generate a Cpp solution to the following problem:
You are given two strings s and t, both consisting only of lowercase Latin letters.
The substring s[l..r] is the string which is obtained by taking characters s_l, s_{l + 1}, ..., s_r without changing the order.
Each of the occurrences of string a in a st... |
#include <bits/stdc++.h>
const int inf = 1000000005;
const long long INF = 3e18;
const double pi = 2 * acos(0.0);
using namespace std;
int gcd(int a, int b) {
a = abs(a);
b = abs(b);
while (b) {
a = a % b;
swap(a, b);
}
return a;
}
int modInverse(int a, int m) {
int m0 = m;
int y = 0, x = 1;
if ... | ### Prompt
Please create a solution in CPP to the following problem:
You are given two strings s and t, both consisting only of lowercase Latin letters.
The substring s[l..r] is the string which is obtained by taking characters s_l, s_{l + 1}, ..., s_r without changing the order.
Each of the occurrences of string a... |
#include <bits/stdc++.h>
using namespace std;
int main() {
string s, t;
int n, m, q, l, r, f[1010] = {0};
cin >> n >> m >> q;
cin >> s >> t;
for (int i = 0; i < n; i++) {
if (s.substr(i, m) == t) f[i] = 1;
}
for (int T = 0; T < q; T++) {
cin >> l >> r;
int c = 0;
for (int i = l - 1; i <= (... | ### Prompt
Create a solution in CPP for the following problem:
You are given two strings s and t, both consisting only of lowercase Latin letters.
The substring s[l..r] is the string which is obtained by taking characters s_l, s_{l + 1}, ..., s_r without changing the order.
Each of the occurrences of string a in a ... |
#include <bits/stdc++.h>
using namespace std;
const int precision = 16;
const int modulo = 1000000007;
using ll = long long;
const double EPS = 1e-9;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
cout.precision(precision);
cout.setf(ios_base::fixed);
int n, m, q;
cin ... | ### Prompt
In CPP, your task is to solve the following problem:
You are given two strings s and t, both consisting only of lowercase Latin letters.
The substring s[l..r] is the string which is obtained by taking characters s_l, s_{l + 1}, ..., s_r without changing the order.
Each of the occurrences of string a in a... |
#include <bits/stdc++.h>
using namespace std;
vector<int> v[102];
bool par[102][102];
bool vis[102];
int cyc = 0;
void dfs(int nd, int p) {
vis[nd] = true;
int z = v[nd].size();
int nx;
for (int i = 0; i < z; i++) {
nx = v[nd][i];
if (vis[nx]) {
if (nx != p && p != 0) {
if (par[nx][nd] || ... | ### Prompt
Develop a solution in CPP to the problem described below:
...Once upon a time a man came to the sea. The sea was stormy and dark. The man started to call for the little mermaid to appear but alas, he only woke up Cthulhu...
Whereas on the other end of the world Pentagon is actively collecting information ... |
#include <bits/stdc++.h>
using namespace std;
const long long maxx = 1e6 + 5;
bool dd[maxx], check, d1[maxx];
long long tr[maxx], val[maxx];
long long b, n, m, k, q, a[maxx], c, f[maxx], x, y, tong = 0;
long long bs(long long v) {
long long l1 = 1, h1 = n, m1;
while (l1 <= h1) {
m1 = (l1 + h1) / 2;
if (a[m1... | ### Prompt
Please formulate a CPP solution to the following problem:
...Once upon a time a man came to the sea. The sea was stormy and dark. The man started to call for the little mermaid to appear but alas, he only woke up Cthulhu...
Whereas on the other end of the world Pentagon is actively collecting information ... |
#include <bits/stdc++.h>
using namespace std;
int P[100001];
void CreateSet(int x) { P[x] = x; }
int FindSet(int x) {
if (x != P[x]) P[x] = FindSet(P[x]);
return P[x];
}
int MergeSets(int x, int y) {
int PX = FindSet(x);
int PY = FindSet(y);
if (PX == PY) return 0;
P[PX] = PY;
return 1;
}
int main() {
i... | ### Prompt
Please create a solution in cpp to the following problem:
...Once upon a time a man came to the sea. The sea was stormy and dark. The man started to call for the little mermaid to appear but alas, he only woke up Cthulhu...
Whereas on the other end of the world Pentagon is actively collecting information ... |
#include <bits/stdc++.h>
using namespace std;
const long long LINF = 1e18;
const int INF = 1e9;
const long double EPS = 1e-9;
const int MOD = 1e9 + 7;
const int N = 105;
vector<int> adj[N];
bitset<N> vis;
int cycle;
void dfs(int v) {
vis[v] = 1;
for (int& u : adj[v]) {
if (vis[u] == 0) dfs(u);
}
}
int main() ... | ### Prompt
Your task is to create a cpp solution to the following problem:
...Once upon a time a man came to the sea. The sea was stormy and dark. The man started to call for the little mermaid to appear but alas, he only woke up Cthulhu...
Whereas on the other end of the world Pentagon is actively collecting inform... |
#include <bits/stdc++.h>
using namespace std;
const double pi = 2 * acos(0.0);
const int inf = 0x3f3f3f3f;
const double infd = 1.0 / 0.0;
long long power(long long x, long long y, long long MOD) {
long long res = 1;
x = x % MOD;
while (y > 0) {
if (y & 1) res = (res * x) % MOD;
y = y >> 1;
x = (x * x)... | ### Prompt
Create a solution in cpp for the following problem:
...Once upon a time a man came to the sea. The sea was stormy and dark. The man started to call for the little mermaid to appear but alas, he only woke up Cthulhu...
Whereas on the other end of the world Pentagon is actively collecting information trying... |
#include <bits/stdc++.h>
using namespace std;
int fp(int abc, int parent[]) {
if (parent[abc] == abc) return abc;
int def = fp(parent[abc], parent);
parent[abc] = def;
return def;
}
void cycledmerge(vector<int> hub[], int n, int parent[]) {
stack<int> urutan;
for (int i = 0; i < n; i++) parent[i] = i;
sta... | ### Prompt
Create a solution in cpp for the following problem:
...Once upon a time a man came to the sea. The sea was stormy and dark. The man started to call for the little mermaid to appear but alas, he only woke up Cthulhu...
Whereas on the other end of the world Pentagon is actively collecting information trying... |
#include <bits/stdc++.h>
using namespace std;
const int N = 110;
vector<int> G[N];
int vis[N];
void DFS(int cur) {
vis[cur]++;
int sz = G[cur].size();
int v;
for (int i = 0; i < sz; i++) {
v = G[cur][i];
if (!vis[v]) DFS(v);
}
}
int main() {
int n, m, u, v;
cin >> n >> m;
for (int i = 0; i < m; ... | ### Prompt
Your challenge is to write a Cpp solution to the following problem:
...Once upon a time a man came to the sea. The sea was stormy and dark. The man started to call for the little mermaid to appear but alas, he only woke up Cthulhu...
Whereas on the other end of the world Pentagon is actively collecting in... |
#include <bits/stdc++.h>
using namespace std;
int n, m, a, b, ciclos, vertice_visited;
int pai[110], vis[110];
vector<int> adj[110];
void dfs(int v) {
vis[v] = 1;
vertice_visited++;
for (int i = 0; i < adj[v].size(); i++) {
int x = adj[v][i];
if (vis[x]) {
if (pai[v] != x) ciclos++;
continue;
... | ### Prompt
In CPP, your task is to solve the following problem:
...Once upon a time a man came to the sea. The sea was stormy and dark. The man started to call for the little mermaid to appear but alas, he only woke up Cthulhu...
Whereas on the other end of the world Pentagon is actively collecting information tryin... |
#include <bits/stdc++.h>
using namespace std;
long long power(long long x, unsigned long long y) {
long long temp;
if (y == 0) return 1;
temp = power(x, y / 2);
if (y % 2 == 0)
return temp * temp;
else
return x * temp * temp;
}
long long modpow(long long x, unsigned int y, long long p) {
long long r... | ### Prompt
In Cpp, your task is to solve the following problem:
...Once upon a time a man came to the sea. The sea was stormy and dark. The man started to call for the little mermaid to appear but alas, he only woke up Cthulhu...
Whereas on the other end of the world Pentagon is actively collecting information tryin... |
#include <bits/stdc++.h>
using namespace std;
vector<int> v[105];
int visit[105];
int c;
void dfs(int i) {
visit[i] = 1;
vector<int>::iterator it;
for (it = v[i].begin(); it != v[i].end(); it++) {
if (visit[(*it)] == 0) {
c++;
dfs((*it));
}
}
}
int main() {
ios_base::sync_with_stdio(0);
... | ### Prompt
Please formulate a CPP solution to the following problem:
...Once upon a time a man came to the sea. The sea was stormy and dark. The man started to call for the little mermaid to appear but alas, he only woke up Cthulhu...
Whereas on the other end of the world Pentagon is actively collecting information ... |
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 111;
int N, M;
int cnt = 0;
vector<int> node[MAXN];
int visited[MAXN];
void dfs(int cur) {
if (visited[cur]) return;
visited[cur] = true;
cnt++;
for (int i = 0; i < node[cur].size(); i++) dfs(node[cur][i]);
}
int main() {
cin >> N >> M;
for (int... | ### Prompt
Construct a Cpp code solution to the problem outlined:
...Once upon a time a man came to the sea. The sea was stormy and dark. The man started to call for the little mermaid to appear but alas, he only woke up Cthulhu...
Whereas on the other end of the world Pentagon is actively collecting information try... |
#include <bits/stdc++.h>
int N, M;
using namespace std;
int cont = 0;
long long parents[101];
long long find(long long n) {
if (n == parents[n]) {
return n;
}
long long aux = find(parents[n]);
parents[n] = aux;
return find(parents[n]);
}
long long Union(long long n1, long long n2) {
long long p1 = find(... | ### Prompt
Your task is to create a CPP solution to the following problem:
...Once upon a time a man came to the sea. The sea was stormy and dark. The man started to call for the little mermaid to appear but alas, he only woke up Cthulhu...
Whereas on the other end of the world Pentagon is actively collecting inform... |
#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
const int maxn = 1e2 + 10;
const double eps = 1e-9;
int mp[maxn][maxn];
int deg[maxn];
int vis[maxn];
int n, m;
void dfs(int u) {
vis[u] = 1;
for (int i = 1; i <= n; i++) {
if (!vis[i] && mp[u][i]) {
dfs(i);... | ### Prompt
Develop a solution in cpp to the problem described below:
...Once upon a time a man came to the sea. The sea was stormy and dark. The man started to call for the little mermaid to appear but alas, he only woke up Cthulhu...
Whereas on the other end of the world Pentagon is actively collecting information ... |
#include <bits/stdc++.h>
using namespace std;
const int N = 200;
int n, m;
int used[N];
vector<int> g[N];
void travel(int u) {
used[u] = 1;
for (auto to : g[u]) {
if (!used[to]) travel(to);
}
}
int cycle_st = -1, cycle_ed = -1;
int p[N];
int dfs(int u, int pr = -1) {
used[u] = 1;
for (auto to : g[u]) {
... | ### Prompt
Please create a solution in CPP to the following problem:
...Once upon a time a man came to the sea. The sea was stormy and dark. The man started to call for the little mermaid to appear but alas, he only woke up Cthulhu...
Whereas on the other end of the world Pentagon is actively collecting information ... |
#include <bits/stdc++.h>
using namespace std;
int par[105];
int getpar(int x) {
if (x == par[x]) return par[x];
par[x] = getpar(par[x]);
return par[x];
}
int main() {
int n, m;
cin >> n >> m;
for (int i = 1; i <= n; ++i) par[i] = i;
for (int i = 1; i <= m; ++i) {
int a, b;
cin >> a >> b;
int p... | ### Prompt
In CPP, your task is to solve the following problem:
...Once upon a time a man came to the sea. The sea was stormy and dark. The man started to call for the little mermaid to appear but alas, he only woke up Cthulhu...
Whereas on the other end of the world Pentagon is actively collecting information tryin... |
#include <bits/stdc++.h>
using namespace std;
int n, m;
int parent[110];
int ranks[110];
int visit[110];
int cycle = 0;
int Findset(int i) {
int root = i;
while (root != parent[root]) root = parent[root];
while (i != root) {
int newp = parent[i];
parent[i] = root;
i = newp;
}
return root;
}
void U... | ### Prompt
Please provide a Cpp coded solution to the problem described below:
...Once upon a time a man came to the sea. The sea was stormy and dark. The man started to call for the little mermaid to appear but alas, he only woke up Cthulhu...
Whereas on the other end of the world Pentagon is actively collecting in... |
#include <bits/stdc++.h>
using namespace std;
vector<int> e[101];
bool used[101];
int cou, d[101];
void dfs(int x, int y, int last) {
d[y] = x;
cou++;
used[x] = 1;
for (int i = 0; i < e[x].size(); i++) {
if (e[x][i] == last) continue;
if (used[e[x][i]]) continue;
dfs(e[x][i], y + 1, x);
}
}
int ma... | ### Prompt
In Cpp, your task is to solve the following problem:
...Once upon a time a man came to the sea. The sea was stormy and dark. The man started to call for the little mermaid to appear but alas, he only woke up Cthulhu...
Whereas on the other end of the world Pentagon is actively collecting information tryin... |
#include <bits/stdc++.h>
int N, M, lv[105], flg = 0, cnt = 0;
struct EDGE {
int s, f, nxt;
EDGE() {}
EDGE(int a, int b, int c) : s(a), f(b), nxt(c) {}
} edge[105 * 105];
int head[105], pE;
void addedge(int s, int f) {
edge[pE] = EDGE(s, f, head[s]);
head[s] = pE++;
edge[pE] = EDGE(f, s, head[f]);
head[f] ... | ### Prompt
Please create a solution in cpp to the following problem:
...Once upon a time a man came to the sea. The sea was stormy and dark. The man started to call for the little mermaid to appear but alas, he only woke up Cthulhu...
Whereas on the other end of the world Pentagon is actively collecting information ... |
#include <bits/stdc++.h>
using namespace std;
int cnt, n, mx, p = 0, parent[101];
void Make_set(int v) { parent[v] = v; }
int Find_set(int v) {
if (parent[v] == v) return v;
return Find_set(parent[v]);
}
void Union_sets(int a, int b) {
a = Find_set(a);
b = Find_set(b);
if (a != b)
parent[b] = a;
else
... | ### Prompt
Develop a solution in CPP to the problem described below:
...Once upon a time a man came to the sea. The sea was stormy and dark. The man started to call for the little mermaid to appear but alas, he only woke up Cthulhu...
Whereas on the other end of the world Pentagon is actively collecting information ... |
#include <bits/stdc++.h>
using namespace std;
int n, m, a[100][100], vis[100], p[100];
void dfs(int x) {
vis[x] = 1;
for (int i = 0; i < n; i++)
if (a[x][i]) {
if (vis[i]) {
if (p[x] != i) m++;
} else {
p[i] = x;
dfs(i);
}
}
}
int main() {
int x, y;
cin >> n >> ... | ### Prompt
Construct a cpp code solution to the problem outlined:
...Once upon a time a man came to the sea. The sea was stormy and dark. The man started to call for the little mermaid to appear but alas, he only woke up Cthulhu...
Whereas on the other end of the world Pentagon is actively collecting information try... |
#include <bits/stdc++.h>
using namespace std;
int table[105][105];
int used[105];
int N, M;
int cycle = 0;
int visit[105];
void DFS(int from, int s) {
int i, j, k;
for (i = 1; i <= N; i++) {
if (table[s][i] && i != from && !visit[i]) {
if (used[i]) {
cycle++;
} else {
used[i] = 1;
... | ### Prompt
Construct a cpp code solution to the problem outlined:
...Once upon a time a man came to the sea. The sea was stormy and dark. The man started to call for the little mermaid to appear but alas, he only woke up Cthulhu...
Whereas on the other end of the world Pentagon is actively collecting information try... |
#include <bits/stdc++.h>
using namespace std;
template <class T1>
void deb(T1 e1) {
cout << e1 << endl;
}
template <class T1, class T2>
void deb(T1 e1, T2 e2) {
cout << e1 << " " << e2 << endl;
}
template <class T1, class T2, class T3>
void deb(T1 e1, T2 e2, T3 e3) {
cout << e1 << " " << e2 << " " << e3 << endl;
... | ### Prompt
Please formulate a cpp solution to the following problem:
...Once upon a time a man came to the sea. The sea was stormy and dark. The man started to call for the little mermaid to appear but alas, he only woke up Cthulhu...
Whereas on the other end of the world Pentagon is actively collecting information ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.