Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- #define ll long long
- #define _test int _TEST; cin>>_TEST; while(_TEST--)
- #define pb push_back
- int main()
- {
- ios_base::sync_with_stdio(false);
- cin.tie(NULL);
- cout.tie(NULL);
- int n, m;
- string s;
- cin>>n>>m>>s;
- vector<int> c(n);
- for(auto &e: c)
- cin>>e;
- vector<vector<int>> pos(m+1);
- for(int i=0; i<n; i++)
- pos[c[i]].pb(i);
- string ans(n, '.');
- for(auto e: pos)
- {
- for(int i=0; i<e.size(); i++)
- ans[e[(i+1)%(e.size())]] = s[e[i]];
- }
- cout<<ans<<"\n";
- }
Advertisement
Add Comment
Please, Sign In to add comment