正文
增加 8 行删除 8 行
17 行未改动1819202122232425262 行未改动2930313233343536372 行未改动4041424344454647488 行未改动575859606162636465666731 行未改动991001011021031041051061071081091101111121131141151161171181191201216 行未改动17 行未改动#include <bits/stdc++.h>using namespace std;map <string, int> mp;map <string, bool> can; // 更改一个字符后可以组成的哞声vector <string> ans;signed main() {2 行未改动string s; cin >> s;for (int i = 0; i < n - 2; i++) {string s1, s2, s3;s1 = s[i]; s2 = s[i + 1]; s3 = s[i + 2];if (s[i] != s[i + 1] && s[i + 1] == s[i + 2]) {for (char j = 'a'; j <= 'z'; j++) {string v = string(1, j) + s2 + s3;if (v == s1 + s2 + s3) continue;2 行未改动if (j != s[i + 1] && v != lst && v != lst2) can[v] = 1, mp[v];}mp[s1 + s2 + s3] ++;}else if (s[i + 1] == s[i + 2])for (char j = 'a'; j <= 'z'; j++) {string v = string(1, j) + s2 + s3;string lst = string(1,s[i-2])+string(1,s[i-1])+string(1,s[i]);string lst2 = string(1,s[i-1])+string(1,s[i])+string(1,s[i+1]);8 行未改动if (s[i] != s[i + 2] && nxt != now1) can[now1] = 1, mp[now1];}}for (auto u : mp)if (u.second + can[u.first] >= f) ans.push_back(u.first);cout << ans.size() << "\n";sort(ans.begin(), ans.end());for (auto u : ans) cout << u << "\n";return 0;31 行未改动for (char b = 'a'; b <= 'z'; b++) {if (a == b) continue;string moo = string(1, a) + string(2, b), s(str);int change = 1, cnt = 0;for (int i = 0; i < n - 2; i++) {string v = string(s, i, 3);if (v == moo) cnt ++, i += 2;else if (diff(v, moo) <= 1 && change && string(s, i + 1, 3) != moo&& string(s, i + 2, 3) != moo) { // 仅相差一位cnt ++;for (int j = 0; j < 3; j++)if (s[i + j] != moo[j]) s[i + j] = moo[j];change --;}}if (cnt >= f) ans.push_back(moo);}cout << ans.size() << "\n";sort(ans.begin(), ans.end());for (auto u : ans) cout << u << "\n";return 0;6 行未改动17 行未改动1819202122232425262 行未改动2930313233343536372 行未改动4041424344454647488 行未改动575859606162636465666731 行未改动991001011021031041051061071081091101111121131141151161171181191201216 行未改动17 行未改动#include <bits/stdc++.h>using namespace std;map <string, int> mp;map <string, bool> can; // 更改一个字符后可以组成的哞声vector <string> ans;signed main() {2 行未改动string s; cin >> s;for (int i = 0; i < n - 2; i++) {string s1, s2, s3;s1 = s[i]; s2 = s[i + 1]; s3 = s[i + 2];if (s[i] != s[i + 1] && s[i + 1] == s[i + 2]) {for (char j = 'a'; j <= 'z'; j++) {string v = string(1, j) + s2 + s3;if (v == s1 + s2 + s3) continue;2 行未改动if (j != s[i + 1] && v != lst && v != lst2) can[v] = 1, mp[v];}mp[s1 + s2 + s3] ++;}else if (s[i + 1] == s[i + 2])for (char j = 'a'; j <= 'z'; j++) {string v = string(1, j) + s2 + s3;string lst = string(1,s[i-2])+string(1,s[i-1])+string(1,s[i]);string lst2 = string(1,s[i-1])+string(1,s[i])+string(1,s[i+1]);8 行未改动if (s[i] != s[i + 2] && nxt != now1) can[now1] = 1, mp[now1];}}for (auto u : mp)if (u.second + can[u.first] >= f) ans.push_back(u.first);cout << ans.size() << "\n";sort(ans.begin(), ans.end());for (auto u : ans) cout << u << "\n";return 0;31 行未改动for (char b = 'a'; b <= 'z'; b++) {if (a == b) continue;string moo = string(1, a) + string(2, b), s(str);int change = 1, cnt = 0;for (int i = 0; i < n - 2; i++) {string v = string(s, i, 3);if (v == moo) cnt ++, i += 2;else if (diff(v, moo) <= 1 && change && string(s, i + 1, 3) != moo&& string(s, i + 2, 3) != moo) { // 仅相差一位cnt ++;for (int j = 0; j < 3; j++)if (s[i + j] != moo[j]) s[i + j] = moo[j];change --;}}if (cnt >= f) ans.push_back(moo);}cout << ans.size() << "\n";sort(ans.begin(), ans.end());for (auto u : ans) cout << u << "\n";return 0;6 行未改动