Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- #define TC ll testcase; cin>>testcase; while(testcase--)
- #define PI 3.14159265359
- #define ll long long
- #define U unsigned
- #define sz(m) (int)(m.size())
- #define endl "\n"
- #define el <<"\n"
- #define OO 2000000000
- #define M0D 1000000007
- #define all(SHA) SHA.begin(),SHA.end()
- #define cin(m) for(auto& it : m)cin>>it
- #define cout(m) for(auto& it : m)cout<<it<<" "
- #define B0Ma ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
- //freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout);
- /* B0Ma
- "Don't lose confidence in your abilities
- * you have more than you can imagine
- * and miracles don't need more than a second to come true "
- */
- int main() {
- B0Ma
- ll x,o; cin>>x>>o;
- string s; cin>>s;
- while (o--){
- string u; cin>>u;
- if(u=="prev_permutation"){
- ll n; cin>>n;
- while (n--){
- prev_permutation(all(s));
- }
- cout<<s el;
- } else{
- ll n; cin>>n;
- while (n--){
- next_permutation(all(s));
- }
- cout<<s el;
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement