Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <algorithm>
- #include <algorithm>
- #include <iostream>
- #include <fstream>
- #include <iomanip>
- #include <stdio.h>
- #include <bitset>
- #include <vector>
- #include <string>
- #include <cmath>
- #include <queue>
- #include <deque>
- #include <map>
- #include <set>
- using namespace std;
- #define pb push_back
- #define mp make_pair
- #define S second
- #define F first
- const int INF = 2e9;
- const long long INFLL = 2e18;
- const int MOD = 1e9 + 7;
- int main()
- {
- //freopen("input.txt", "r" , stdin);
- //freopen("output.txt", "w" , stdout);
- //
- freopen("locker.in", "r" , stdin);
- freopen("locker.out", "w" , stdout);
- string s;
- cin >> s;
- vector < int > a;
- for (int i = 0; i < s.length() / 2; i++){
- if (s[i] != s[s.length() - i - 1]){
- a.push_back(i);
- a.push_back(s.length() - i - 1);
- }
- }
- if (a.size() == 0){
- cout << "YES";
- return 0;
- }
- if (a.size() > 10){
- cout << "NO";
- return 0;
- }
- string t;
- if (s.length() % 2 == 1){
- a.push_back((s.length()) / 2);
- }
- for (int i = 0; i < a.size(); i++){
- for (int j = i + 1; j < a.size(); j++){
- int x = a[i] , y = a[j];
- swap(s[x] , s[y]);
- t = s;
- reverse(t.begin() , t.end());
- if (s == t){
- cout << "YES";
- return 0;
- }
- swap(s[x] , s[y]);
- }
- }
- cout << "NO";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement