intcatseq(string s, string t){ int m = t.size(); vector<array<int, 26>> next(m + 2); t = " " + t; for (int i = m; i >= 1; i--) { for (int j = 0; j < 26; j++) { if (j == t[i] - 'a') next[i][j] = i + 1; else { next[i][j] = next[i + 1][j]; } } } int p = 1; int ans = 1; deb(s); for (auto x : s) { p = next[p][x - 'a']; deb(p); if (p == 0) { ans++; p = 1; p = next[p][x - 'a']; if (p == 0) return-1; } }