Advertisement
fuadnafiz98

Untitled

Mar 16th, 2021
877
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.28 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. string sol(string s) {
  6.   if(next_permutation(s.begin(),s.end()))
  7.     return s;
  8.   else
  9.   return "no answer";
  10. }
  11.  
  12.  
  13. int main() {
  14.   int t;
  15.   cin >> t;
  16.   while(t--) {
  17.     string x;
  18.     cin >> x;
  19.     cout << sol(x) << "\n";
  20.   }
  21. }
  22.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement