BWT by teebee

import java.util.*;enum W{W;System z;{for(Scanner s=new Scanner(z.in);s==s;){TreeSet t=new TreeSet();String a="",b,c=s.nextLine();int r=c.length(),i=0,f=r+1;for(;i<r;)t.add(c.substring(i++)+c);for(i=0;i<r;i++){b=(String)t.toArray()[i];if(f>r&b.indexOf(c)==0)f=i;a+=b.charAt(r-1);}z.out.println(f+" "+a);}}}

Note that non-ascii characters in the above source code will be escaped (such as \x9f).

download

return to the top page