Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- #define ll long long
- #define mp make_pair
- #define pb push_back
- #define pii pair <int, int>
- #define vi vector<int>
- #define read1(a) int a; scanf("%d", &a)
- #define read2(a, b) int a, b; scanf("%d %d", &a, &b)
- #define read3(a, b, c) int a, b, c; scanf("%d %d %d", &a, &b, &c)
- #define FOR(i, a, b) for (int i=a; i<b; i++)
- #define F0R(i, a) for (int i=0; i<a; i++)
- #define readgi(n) F0R(i, n) { scanf("%d", &arr[i]); }
- #define readgs(n) F0R(i, n) { scanf(" %c", &arr[i]); }
- #define f first
- #define s second
- const int MOD = 1000000007;
- const int MAX = 100005;
- int b[MAX];
- string s;
- void kmp()
- {
- int i=0, j=-1;
- b[i]=j;
- while (i<s.length())
- {
- while (j>=0 && s[i]!=s[j]) j=b[j];
- i++; j++;
- b[i]=j;
- }
- }
- int main() {
- s = "ababaa";
- kmp();
- F0R(i, 10) { cout << b[i] << " ";}
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement