This documentation is automatically generated by online-judge-tools/verification-helper
#define PROBLEM "http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_14_B"
#include "../../code/strings/kmp.cc"
int main() {
cin.tie(0);
ios_base::sync_with_stdio(0);
string s, s2;
cin >> s >> s2;
vi res = match(s, s2);
for(int i : res)
cout << i << endl;
}
#line 1 "tests/aoj/kmp.string_matches.test.cpp"
#define PROBLEM "http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_14_B"
#line 1 "code/template.cc"
// this line is here for a reason
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define fi first
#define se second
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define endl '\n'
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define SZ(x) (int)(x).size()
#define FOR(a, b, c) for (auto a = (b); (a) < (c); ++(a))
#define F0R(a, b) FOR (a, 0, (b))
template <typename T>
bool ckmin(T& a, const T& b) { return a > b ? a = b, true : false; }
template <typename T>
bool ckmax(T& a, const T& b) { return a < b ? a = b, true : false; }
#ifndef DEBUG
#define DEBUG 0
#endif
#define dout if (DEBUG) cerr
#define dvar(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#line 2 "code/strings/kmp.cc"
vi preprocess(string& s) {
vi fail(SZ(s) + 1);
fail[0] = -1;
for (int i = 0, j = -1; i < SZ(s);) {
while (j >= 0 && s[i] != s[j]) j = fail[j];
++i, ++j;
fail[i] = j;
}
return fail;
}
vi match(string& text, string& pattern) {
vi matches, fail(preprocess(pattern));
for (int i = 0, j = 0; i < SZ(text);) {
while (j >= 0 && text[i] != pattern[j]) j = fail[j];
++i; ++j;
if (j == SZ(pattern)) {
matches.pb(i - j);
j = fail[j];
}
}
return matches;
}
#line 4 "tests/aoj/kmp.string_matches.test.cpp"
int main() {
cin.tie(0);
ios_base::sync_with_stdio(0);
string s, s2;
cin >> s >> s2;
vi res = match(s, s2);
for(int i : res)
cout << i << endl;
}