Reverse BWT by 7gyou

class U{static public void main(String[]A){try{for(int i,L,l,c,x,n;;){char s[]=new java.io.DataInputStream(System.in).readLine().toCharArray(),a;for(i=c=n=0;s[i++]>32;)n=n*10+s[i-1]%48;for(L=l=s.length-i;l>-1;c=x+1){for(x=a=0;(c-=a==s[i+x]?1:0)>0;a+=x>0?0:1)x=++x%L;if(n<0)System.out.print(l-->0?a:'\n');if(x==n)n=-1;}}}catch(Exception e){}}}

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

download

return top