Advertisement
MiinaMagdy

146 - ID Codes

Sep 11th, 2022
733
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.45 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. #define ll long long
  6. #define endl '\n'
  7. #define sz(x) int(x.size())
  8. #define all(x) x.begin(), x.end()
  9.  
  10. int main() {
  11.     ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  12.     string s;
  13.     while (cin >> s, s != "#") {
  14.         if (is_sorted(all(s), [](char a, char b) {
  15.                 return a > b;
  16.             })) {
  17.             cout << "No Successor\n";
  18.         }
  19.         else {
  20.             next_permutation(all(s));
  21.             cout << s << endl;
  22.         }
  23.     }
  24. }
  25.  
Tags: UVA CP3
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement