Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define forn(i, n) for(unsigned int i = 0; i < n; i++)
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- int sol0() {
- char sh[1000];
- scanf("%s\n", sh);
- char str[1000];
- fgets(str, 1000, stdin);
- unsigned int d['z' + 1];
- forn(i, 'z' + 1)
- d[i] = strlen(sh);
- forn(i, strlen(sh) - 1)
- {
- d[sh[i]] = strlen(sh) - i - 1;
- }
- unsigned int k = strlen(sh) - 1;
- while (k < strlen(str))
- {
- unsigned int y = strlen(sh), j = 1;
- if (!(sh[y - 1] == str[k]))
- {
- printf("%d ", k + 1);
- k += d[str[k]];
- }
- else {
- while (j <= y && sh[y - j] == str[k - j + 1])
- {
- printf("%d ", k - j + 2);
- j++;
- }
- if (j <= y)
- {
- printf("%d ", k - j + 2);
- }
- k += d[str[k]];
- }
- }
- return 0;
- }
- int main() {
- sol0();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement