MAGCARI

Reverse

Oct 24th, 2022
877
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.53 KB | None | 0 0
  1. /*
  2.     Task    : Reverse
  3.     Author  : Phumipat C. [MAGCARI]
  4.     Language: C++
  5.     Created : 24 October 2022 [20:55]
  6. */
  7. #include<bits/stdc++.h>
  8. using namespace std;
  9. int qs[100010];
  10. char s[100010];
  11. int main(){
  12.     cin.tie(0)->sync_with_stdio(0);
  13.     cin.exceptions(cin.failbit);
  14.     int q;
  15.     cin >> q;
  16.     while(q--){
  17.         int m,x;
  18.         cin >> s+1 >> m;
  19.         int n = strlen(s+1);
  20.         memset(qs,0,sizeof qs);
  21.         for(int i=1;i<=m;i++)
  22.             cin >> x,qs[x]++;
  23.         for(int i=1;i<=(n+1)/2;i++){
  24.             qs[i]+=qs[i-1];
  25.             if(qs[i]%2==1)
  26.                 swap(s[i],s[n-i+1]);
  27.         }
  28.         cout << s+1 << '\n';
  29.     }
  30.     return 0;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment