You are viewing a single comment's thread. Return to all comments →
C++ solution
#include <cmath> #include <cstdio> #include <vector> #include <iostream> #include <algorithm> using namespace std; string s; int main() { int tc; scanf("%d", &tc); while (tc--) { cin >> s; if (next_permutation(s.begin(), s.end())) printf("%s\n", s.c_str()); else printf("no answer\n"); } return 0; }
Seems like cookies are disabled on this browser, please enable them to open this website
Bigger is Greater
You are viewing a single comment's thread. Return to all comments →
C++ solution