Advertisement
bibaboba12345

Untitled

Jan 10th, 2023
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.47 KB | None | 0 0
  1. // clang-format off
  2. #define _CRT_SECURE_NO_WARNINGS
  3. #include <iostream>
  4. #include <iomanip>
  5. #include <bitset>
  6. #include <vector>
  7. #include <algorithm>
  8. #include <random>
  9. #include <map>
  10. #include <string>
  11. #include <set>
  12. #include <deque>
  13. #include <string>
  14. #include <cassert>
  15.  
  16. #pragma GCC optimize("Ofast")
  17.  
  18. using namespace std;
  19. const int N = 1e6 + 7, MOD = 1e9 + 7, C = 1000, C2 = 10;
  20. const long long INF = 1e18;
  21. const long double EPS = 1e-9;
  22. int x, n;
  23. string s;
  24.  
  25. vector<string> answ;
  26. set<string> a;
  27.  
  28. int diff(string s1) {
  29. int answ = 0;
  30. for (int i = 0; i < n; i++) {
  31. if (s1[i] != s[i]) {
  32. answ++;
  33. }
  34. }
  35. return answ;
  36. }
  37. signed main() {
  38. #ifdef _DEBUG
  39. freopen("input.txt", "r", stdin);
  40. #else
  41. std::ios::sync_with_stdio(false);
  42. cin.tie(0);
  43. #endif
  44. cin >> x >> s;
  45. n = s.size();
  46. for (int i = 0; i < n; i++) {
  47. for (int j = 0; j < n; j++) {
  48. for (int k = 0; k < n; k++) {
  49. string s1 = s;
  50. s1[i] = s[j];
  51. s1[j] = s[k];
  52. s1[k] = s[i];
  53. if (diff(s1) <= 3 && diff(s1) != 0 && a.find(s1) == a.end() && s1 != s) {
  54. if (answ.size() < x) {
  55. answ.push_back(s1);
  56. a.insert(s1);
  57. }
  58. }
  59. }
  60. }
  61. }
  62. assert(answ.size() == x);
  63. for (auto u : answ) {
  64. cout << u << '\n';
  65. }
  66. }
  67.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement