Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // clang-format off
- #define _CRT_SECURE_NO_WARNINGS
- #include <iostream>
- #include <iomanip>
- #include <bitset>
- #include <vector>
- #include <algorithm>
- #include <random>
- #include <map>
- #include <string>
- #include <set>
- #include <deque>
- #include <string>
- #include <cassert>
- #pragma GCC optimize("Ofast")
- using namespace std;
- const int N = 1e6 + 7, MOD = 1e9 + 7, C = 1000, C2 = 10;
- const long long INF = 1e18;
- const long double EPS = 1e-9;
- int x, n;
- string s;
- vector<string> answ;
- set<string> a;
- int diff(string s1) {
- int answ = 0;
- for (int i = 0; i < n; i++) {
- if (s1[i] != s[i]) {
- answ++;
- }
- }
- return answ;
- }
- signed main() {
- #ifdef _DEBUG
- freopen("input.txt", "r", stdin);
- #else
- std::ios::sync_with_stdio(false);
- cin.tie(0);
- #endif
- cin >> x >> s;
- n = s.size();
- for (int i = 0; i < n; i++) {
- for (int j = 0; j < n; j++) {
- for (int k = 0; k < n; k++) {
- string s1 = s;
- s1[i] = s[j];
- s1[j] = s[k];
- s1[k] = s[i];
- if (diff(s1) <= 3 && diff(s1) != 0 && a.find(s1) == a.end() && s1 != s) {
- if (answ.size() < x) {
- answ.push_back(s1);
- a.insert(s1);
- }
- }
- }
- }
- }
- assert(answ.size() == x);
- for (auto u : answ) {
- cout << u << '\n';
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement