fork download
  1. #pragma GCC optimize("Ofast,fast-math,unroll-loops,no-stack-protector")
  2. #include <stdio.h>
  3. int k,q,r,i,j,x;
  4. char s1[21],s2[21],*ps1=s1,*ps2=s2,*t,a[21][21];
  5. int main(){
  6. scanf("%d %d %d\n%s",&k,&q,&r,s1);
  7. for(i=0;i<q;++i){
  8. for(j=0;j<k;++j){
  9. scanf("%d",&x);--x;
  10. *(ps2+x)=*(ps1+j);
  11. if(x<r)a[i][x]=*(ps1+j);
  12. if(j==r)a[i][j]='\0';
  13. }
  14. t=ps1;ps1=ps2;ps2=t;
  15. }
  16. for(i=0;i<k;++i)printf("%s\n",a[i]);
  17. return 0;
  18. }
Success #stdin #stdout 0s 5512KB
stdin
5 4 1
abcde
2 1 3 5 4
5 1 2 4 3
4 1 2 3 5
3 1 4 5 2
stdout
b
a
c
d