Algorithm


J. Spelling Check
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

Petya has noticed that when he types using a keyboard, he often presses extra buttons and adds extra letters to the words. Of course, the spell-checking system underlines the words for him and he has to click every word and choose the right variant. Petya got fed up with correcting his mistakes himself, that’s why he decided to invent the function that will correct the words itself. Petya started from analyzing the case that happens to him most of the time, when all one needs is to delete one letter for the word to match a word from the dictionary. Thus, Petya faces one mini-task: he has a printed word and a word from the dictionary, and he should delete one letter from the first word to get the second one. And now the very non-trivial question that Petya faces is: which letter should he delete?

Input

The input data contains two strings, consisting of lower-case Latin letters. The length of each string is from 1 to 106 symbols inclusive, the first string contains exactly 1 symbol more than the second one.

Output

In the first line output the number of positions of the symbols in the first string, after the deleting of which the first string becomes identical to the second one. In the second line output space-separated positions of these symbols in increasing order. The positions are numbered starting from 1. If it is impossible to make the first string identical to the second string by deleting one symbol, output one number 0.

Examples
input
Copy
abdrakadabra
abrakadabra
output
Copy
1
3
input
Copy
aa
a
output
Copy
2
1 2
input
Copy
competition
codeforces
output
Copy
0



 

Code Examples

#1 Code Example with C++ Programming

Code - C++ Programming

#include <iostream>
#include <vector>

int main(){

    std::ios_base::sync_with_stdio(false);
    std::string s, t; std::cin >> s >> t;

    long ind(0), pos(s.size() - 1); bool inc(false), possible(true);
    for(long p = 0; p < t.size(); p++){
        if(t[p] == s[ind]){++ind;}
        else if(!inc && t[p] == s[ind + 1]){pos = ind; ind += 2; inc = true;}
        else{possible = false; break;}
    }

    if(possible){
        std::vector<long> v;
        for(long p = pos; p >= 0; p--){
            if(s[p] == s[pos]){v.push_back(p + 1);}
            else{break;}
        }

        printf("%ld\n", v.size());
        for(long p = v.size() - 1; p >= 0; p--){printf("%ld ", v[p]);}
        puts("");
    }
    else{puts("0");}

    return 0;
}
Copy The Code & Try With Live Editor

Input

x
+
cmd
abdrakadabra
abrakadabra

Output

x
+
cmd
1
3
Advertisements

Demonstration


Codeforces Solution-J. Spelling Check-Solution in C, C++, Java, Python

Previous
Codeforces solution 1080-B-B. Margarite and the best present codeforces solution
Next
CodeChef solution DETSCORE - Determine the Score CodeChef solution C,C+