Dataset Viewer (First 5GB)
Auto-converted to Parquet Duplicate
output
stringlengths
52
181k
instruction
stringlengths
296
182k
#include <bits/stdc++.h> using namespace std; void qmax(int &x, int y) { if (x < y) x = y; } void qmin(long long &x, long long y) { if (x > y) x = y; } inline long long read() { char s; long long k = 0, base = 1; while ((s = getchar()) != '-' && s != EOF && !(isdigit(s))) ; if (s == EOF) exit(0); 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 N, M, Q; string S, T; int ok[1010]; void solve() { int i, j, k, l, r, x, y; string s; cin >> N >> M >> Q >> S >> T; for (i = 0; i < (N); i++) { ok[i + 1] = ok[i]; if (i + M <= N) { x = 1; for (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 main() { string s, t; int n, m, q, l, r; cin >> n >> m >> q; cin >> s >> t; int arr[10000] = {0}; for (int i = 0; i <= n - m; ++i) { arr[i + 1] = arr[i] + (s.substr(i, m) == t); } while (q--) { cin >> l >> r; if (r - l + 1 < m) cout << ...
### 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, pre[2005], q; char s[2005], t[2005]; int main() { scanf("%d%d%d", &n, &m, &q); scanf("%s%s", s, t); for (int i = 0; i < n - m + 1; i++) { int flag = 1; for (int j = 0; j < m; j++) if (s[i + j] != t[j]) { flag = 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 n, m, Q, cnt = 0; int a[1010], L[1010]; char s[1010], t[1010]; int main() { scanf("%d%d%d", &n, &m, &Q); scanf("%s%s", s, t); for (int i = 0; i < n; i++) { if (s[i] == t[0]) { bool bo = 0; for (int j = 1; j < m; j++) { if (s[i + j] != t[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; int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); long long n, m, q; string s, t; cin >> n >> m >> q >> s >> t; map<long long, long long> d; long long cont = 0; for (long long i = (0); i < (long long)(n); i++) { if (s.substr(i, m) == 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> using namespace std; int fx[] = {-1, 1, 0, 0}; int fy[] = {0, 0, -1, 1}; int dx[] = {1, 1, 0, -1, -1, -1, 0, 1}; int dy[] = {0, 1, 1, 1, 0, -1, -1, -1}; int kx[] = {1, 1, -1, -1, 2, 2, -2, -2}; int ky[] = {2, -2, 2, -2, 1, -1, 1, -1}; bool cmp(const pair<int, int> &a, const pair<int, int> &b) {...
### 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 INF = 0x3f3f3f3f; int main() { int n, m, q; cin >> n >> m >> q; string a, b; cin >> a >> b; int mark[1000]; memset(mark, 0, sizeof(mark)); for (int i = 0; i < n; i++) { if (a[i] == b[0]) { int flag = 1, j; for (j = 1; j < m && 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; const int maxn = 2e3 + 5; char a[maxn], b[maxn]; int sum[maxn]; int n, m, q; void solve() { for (int i = 0; i < n; i++) { int flag = 1; for (int j = 0; j < m; j++) if (a[i + j] != b[j]) { flag = 0; break; } if (flag) sum[i + 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 n, m, q; int ans[1005]; int main() { while (scanf("%d%d%d", &n, &m, &q) != EOF) { string s1, s2; cin >> s1 >> s2; for (int i = 0; i + m <= n; i++) { if (s1.substr(i, m) == s2) ans[i + 1]++; } for (int i = 2; i <= n; i++) ans[i] += ans[i - 1];...
### 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; char s[1002], t[1002]; int v[1002]; int main() { int n, m, q, l, r, sol, i, ok, j; cin >> n >> m >> q; cin.get(); cin.getline(s, 1001); cin.getline(t, 1001); for (i = 0; i < n - m + 1; i++) { ok = 1; for (j = i; j <= i + m - 1; j++) if (t[j - 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; const int inf = 1e9 + 7; const long long INF = 1LL << 60; const long long mod = 1e9 + 7; const long double eps = 1e-8; const long double pi = acos(-1.0); template <class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template <cl...
### 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; void z_function(string &s, vector<int> &z) { int n = s.length(), l = -1, r = -1; z.clear(); z.resize(n, 0); z[0] = n; for (int i = 0; i < n; i++) { if (i <= r) z[i] = min(r - i + 1, z[i - l]); while (z[i] + i < n && s[z[i]] == s[z[i] + i]) z[i]++; 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; const int MX = 1e3; int sum[MX + 2]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); long long n, m, q, l, r; string str, str2; cin >> n >> m >> q; cin >> str >> str2; for (long long i = 0; i < n - m + 1; i++) { sum[i] = (str.substr(i, m) == ...
### 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> vet; int p[201010]; void kmp(string &s, int sz) { p[0] = 0; int idx = 0, n = (int)s.size(); for (int i = 1; i < n; i++) { while (s[idx] != s[i] && idx > 0) idx = p[idx - 1]; if (s[idx] == s[i]) idx++; p[i] = idx; if (p[i] == sz) { vet...
### 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> #pragma GCC optimize(2) #pragma GCC optimize(3) #pragma GCC optimize(4) using namespace std; const int N = 1e3 + 5; int sum[N]; int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); ; int n, m, q, l, r; string s, t; cin >> n >> m >> q; cin >> s >> t; for (int 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; const double PI = 2 * acos(0.0), EPS = 1e-9; const int INF = 1e9, NINF = -1e9, MOD = 1e9 + 7; void GO() { cout << fixed << setprecision(10); } int main() { GO(); int n, m, q, r, l, c, a[1001] = {}; string second, t; cin >> n >> m >> q >> second >> t; for (int i = ...
### 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 N = 1111; string s, t; int sum[N]; int n, m, q; signed main() { ios_base::sync_with_stdio(false); cin >> n >> m >> q >> s >> t; for (int i = (1); i <= (n); i++) { bool found = true; for (int j = (0); j <= (m - 1); j++) { int ii = i - 1 + j; ...
### 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 long long mod = 1e9 + 7; const int maxn = 1010; char a[maxn], b[maxn]; int n, m, q; vector<int> pos; void solve() { while (q--) { int l, r, tr; scanf("%d%d", &l, &r); tr = r - m + 1; if (l > tr) puts("0"); else { printf("%d\n", ...
### 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 n, m, q, dp[10004]; string s, t; int main() { cin >> n >> m >> q >> s >> t; for (int i = 0, ok = true; i <= n - m; ++i, ok = true) { for (int j = 0; j < m; ++j) { if (s[i + j] != t[j]) ok = false; } dp[i + 1] = dp[i] + ok; } for (int i = 0, l, ...
### 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; int occ[n]; int sta[n]; int sum[n]; for (int o = 0; o < n; o++) { occ[o] = 0; sum[o] = 0; sta[o] = 0; } int v = 0; for (int e = 0; e < n - m + 1; e++) { int 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> int n, m, q, a0, a1; char s[1003], t[1003]; int pp[1003]; int main() { scanf("%d %d %d", &n, &m, &q); scanf("%s", s); scanf("%s", t); for (int i = 0; i <= n - m; ++i) { int j = 0; for (; j < m && s[i + j] == t[j]; ++j) ; if (j == m) pp[i] = 1; } for (int i = 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 z[1000005]; string s; void Z() { int n = s.size(), l = 0, r = 0, i; for (i = 0; i < n; i++) { if (i > r) { l = r = i; while (r < n && s[r] == s[r - l]) { r++; } z[i] = r - l; r--; } else { if (i + z[i - l] <= r) { ...
### 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; vector<int> l, r; int main() { string s, t; int n, m, q, x, y; cin >> n >> m >> q >> s >> t; for (int i = 0; i < n; i++) { int flag = 1; if (s[i] == t[0]) { for (int j = i, k = 0; j < n && k < m; j++, k++) if (s[j] != t[k]) { flag = 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; const int64_t MOD = 1e9 + 7; const int64_t N = 2e6; bool isQuery = false; int64_t power(int64_t x, int64_t n) { if (n == 0) return 1; else if (n % 2 == 0) return power(x, n / 2) * power(x, n / 2); else return x * power(x, n / 2) * power(x, n / 2); } int64_...
### 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, i, q, j, k, l, count, c, p = 0, a[1001] = {0}; cin >> n >> m >> q; string s, t; cin >> s >> t; for (i = 0; i <= n - m; i++) { if (s.substr(i, m) == t) a[i] = {1}; } for (i = 1; i <= q; i++) { long long d, e; c = 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; int n, m, q; string s; string t; int d[1001]; bool check(string s) { for (int i = 0; i < s.length(); i++) { if (s[i] != t[i]) return false; } return true; } int main() { cin >> n >> m >> q; cin >> s >> t; for (int i = 0; i < n - m + 1; i++) { string tmp ...
### 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 a[1001]; int main() { int i, n, m, q, j, l, r; string str1, str2; cin >> n >> m >> q; cin >> str1; cin >> str2; for (i = 0; i <= n - m; i++) { for (j = 0; j < m; j++) { if (str1[i + j] != str2[j]) { break; } } if (j == m) a[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 maxn = 10005; int Next[maxn]; char str[maxn], th[maxn]; int change(char s[]) { int i = 0, j = 1; Next[i] = 0; while (s[j]) { if (s[i] == s[j]) { i++; Next[j] = i; j++; } else { if (i > 0) { i = Next[i - 1]; } els...
### 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() { int n, m, q; string s, t; cin >> n >> m >> q; cin >> s >> t; vector<int> v; v.clear(); if (n < m) { for (int i = 0; i < q; i++) { int a, b; cin >> a >> b; cout << "0" << endl; } return 0; } for (int i = 0; i <= s....
### 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, sum[1001]; string s1, s2; int main() { cin >> n >> m >> q >> s1 >> s2; for (int i = 1; i <= n; i += 1) { sum[i] += sum[i - 1]; if (i > n - m + 1) { continue; } bool f = true; for (int j = i; j < i + m; j += 1) { if (s1[j - 1]...
### 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; char s[1005], t[1005]; int sum[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 good = 1; for (int j = 1; j <= m; j++) { if (s[i + j - 1] != t[j]) good = 0; } sum[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 dp[2000]; char str[2000], tr[2000]; int main() { int i, j, k, l, m, n, q; scanf("%d%d%d", &n, &m, &q); scanf("%s", str + 1); scanf("%s", tr + 1); for (int i = 1; str[i]; i++) { for (j = 1, k = i; tr[j] && str[k]; j++, k++) { if (tr[j] != str[k]) brea...
### 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 = 1001; int a[maxn], cnt = 0; char s1[maxn], s2[maxn]; int main() { int n, m, q; scanf("%d%d%d", &n, &m, &q); cin >> s1 >> s2; for (int i = 0; i < n; i++) { if (s1[i] == s2[0]) { bool fa = 1; int now = i; for (int j = 1; j < m; j...
### 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; long long mod = 1000000007; long long z[3000019], arr[3000019], pre[3000019]; void fnc(string s) { memset(z, 0, sizeof(z)); long long l = 0, r = 0; long long n = s.size(); for (long long i = 1; i <= n; i++) { if (i <= r) z[i] = min(r - i + 1, z[i - l]); whil...
### 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 argc, const char* argv[]) { int64_t n, m, q; string s, t; cin >> n >> m >> q >> s >> t; vector<pair<int, int>> ins; for (int i = 0; i < s.size(); ++i) { if (i + t.size() - 1 < s.size() && s.substr(i, t.size()) == t) { ins.push_back(make_pair...
### 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> I; for (int i = 0; i < n - m + 1; i++) { if (t == s.substr(i, m)) I.push_back(i); } for (int i = 0; i < q; i++) { int l, r; cin >> l >> r; l--; r--; ...
### 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; void solve() { int n, m, q; cin >> n >> m >> q; string s, t; cin >> s >> t; vector<int> v; for (int i = 0; i < int((s).size()); i++) { int j; for (j = 0; j < int((t).size()) && (i + j) < int((s).size()); j++) { if (s[j + i] != t[j]) break; } ...
### 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, dp[1010][1010]; char s[1010], t[1010]; bool used[1010]; int main() { scanf("%d%d%d", &n, &m, &q); scanf("%s", s + 1); scanf("%s", t); for (int i = 1; i + m - 1 <= n; i++) { bool f = true; for (int j = 0; j < m; j++) { if (s[i + j] != t[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; int main() { int n, m, q; cin >> n >> m >> q; string s, t; cin >> s >> t; vector<bool> occ(n); for (int i = 0; i < n; i++) { if (s.substr(i, m) == t) { occ[i] = 1; } } vector<int> prefixOcc(n + 1); prefixOcc[0] = 0; for (int i = 1; i <= n; ...
### 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; string s, t; long long m, n, q, dp[1010][1010]; int main() { cin >> n >> m >> q; cin >> s >> t; for (int i = 0; i <= n - m; i++) { bool b = false; for (int j = i; j < i + m; j++) { if (s[j] != t[j - i]) b = true; } if (b == false) { dp[i][i...
### 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 MOD = 1e9 + 7; vector<long long> build(string s) { int n = s.size(); vector<long long> kmp(n, 0); for (int i = 1; i < n; i++) { int j = kmp[i - 1]; while (j > 0 && s[i] != s[j]) { j = kmp[j - 1]; } if (s[i] == s[j]) j++; kmp[i] = j;...
### 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 = 1e5 + 20; int sum[maxn]; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n, m, q; cin >> n >> m >> q; string s, t; cin >> s >> t; for (int i = 0; i < n; i++) sum[i + 1] = sum[i] + (i + m <= n && s.substr(i, m)...
### 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() { long long n, m, q; cin >> n >> m >> q; string s; cin >> s; string t; cin >> t; string str1 = s; size_t pos1; vector<long long> arr; pos1 = str1.find(t); while (pos1 != string::npos) { arr.push_back(pos1); pos1 = str1.find(t, pos1 +...
### 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 int64_t MOD = 1e9 + 7; const int64_t N = 2e6; bool isQuery = false; int64_t power(int64_t x, int64_t n) { if (n == 0) return 1; else if (n % 2 == 0) return power(x, n / 2) * power(x, n / 2); else return x * power(x, n / 2) * power(x, n / 2); } int64_...
### 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 st[1001]; int main() { int n, m, q; cin >> n >> m >> q; string s; cin >> s; string t; cin >> t; st[0] = 0; for (int i = 1; i <= n - m + 1; i++) { bool b = true; for (int j = i; j < i + m; j++) { if (s.at(j - 1) != t.at(j - i)) { b =...
### 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 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 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 n, m, q, lct1, lct2; string s, t; int z[3005]; int cnt; int main() { ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL); cin >> n >> m >> q; cin >> s >> t; s = t + s; int len = s.length(); z[0] = 0; for (int i = 1, l = 0, r = 0; i < len; ++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; struct Node { int d; struct Node *left, *right; }; int p[1000][1000] = {0}; string s, t; void dp(int i, int j) { if (j - i + 1 == t.size()) { int f = 1; for (int z = 0; z < t.size(); z++) { if (s[i + z] != t[z]) { f = 0; break; } ...
### 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 s, t; vector<int> can; int n, m, k; int main() { cin >> n >> m >> k; cin >> s >> t; for (int i = 0; i <= n - m; i++) { if (s.substr(i, m) != t) continue; can.push_back(i + 1); } while (k--) { int l, r; cin >> l >> r; r = r - m + 1; 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; int n, m, q, l, r, vf, ans, i, j, k; const int LMAX = 1e3; char s[LMAX + 5], t[LMAX + 5]; int st[LMAX + 5], dr[LMAX + 5], cnt = 0; int main() { cin >> n >> m >> q; for (i = 1; i <= n; i++) cin >> s[i]; for (i = 1; i <= m; i++) cin >> t[i]; for (i = 1; i <= n - m + 1...
### 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() { ios_base::sync_with_stdio(false); cin.tie(NULL); string s, t; int n, m, q, ct = 0, flag, l, r; cin >> n >> m >> q; vector<vector<int>> ans(n + 1, vector<int>(n + 1, 0)); cin >> s; cin >> t; for (int i = 0; i < n; i++) { flag = 1; for (...
### 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; string str; vector<int> z; int len = 0; void zfunc() { len = str.size(); z.resize(len); int ind = 0; for (int i = 1; i < len; i++) { if (ind + z[ind] - 1 >= i) { z[i] = min(ind + z[ind] - i, z[i - ind]); } for (; i + z[i] < len && str[i + z[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; char s[100005], t[100005]; int Q, m, n, l1, l2; int sum[100005], fr[100005], ma[100005]; void init() { int i, np; scanf("%d%d%d", &l1, &l2, &Q); scanf("%s", s); scanf("%s", t); for (i = l1; i > 0; i--) s[i] = s[i - 1]; for (i = l2; i > 0; i--) t[i] = t[i - 1]; ...
### 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 ans[1005]; int main() { long long n, m, k; string a, b; cin >> n >> m >> k; cin >> a >> b; for (int i = 0; i <= n - m; i++) { ans[i + 1] = ans[i] + (a.substr(i, m) == b); } while (k--) { long long l, r; cin >> l >> r; if (r - l + 1 < ...
### 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 maxn = 1000 + 10; int main() { int n, q, g; int index; int a[1005]; int k = 0; string s, t; string ss[1005]; scanf("%d%d%d", &n, &q, &g); getchar(); cin >> s >> t; for (int i = 0; i < n; i++) { string str = s.substr(i, q); if (str == t)...
### 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 arr[1001] = {0}; int u[200001] = {0}; int main() { ios::sync_with_stdio(false); int n, m, q, i, l, r; cin >> n >> m >> q; string s, t, ch; cin >> s >> t; int pos = -1, x = 0; while (pos + 1 < s.size() && s.find(t, pos + 1) != string::npos) { pos = s.fi...
### 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 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 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; inline int two(int n) { return 1 << n; } inline void set_bit(int& n, int b) { n |= two(b); } inline void unset_bit(int& n, int b) { n &= ~two(b); } inline int last_bit(int n) { return n & (-n); } template <class T> T gcd(T a, T b) { return (b != 0 ? gcd<T>(b, a % b) : a);...
### 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...
End of preview. Expand in Data Studio

No dataset card yet

Downloads last month
5