fork download
  1. #include<bits/stdc++.h>
  2.  
  3. #pragma GCC optimize("O2")
  4. #pragma GCC optimize("O3")
  5. #pragma GCC optimize("Ofast")
  6.  
  7. #define int long long
  8.  
  9. #define pii pair<int,int>
  10. #define ii int,int
  11. #define fi first
  12. #define se second
  13. #define pb push_back
  14. #define lb lower_bound
  15. #define ub upper_bound
  16. #define umap unordered_map
  17. #define BIT(mask, i) ((mask >> i)&1)
  18. #define ALL(c) c.begin(), c.end()
  19.  
  20. using namespace std;
  21.  
  22. mt19937 rd(chrono::high_resolution_clock::now().time_since_epoch().count());
  23. int rand(int l, int r){
  24. return l + rd()*rd()%(r-l+1);
  25. }
  26.  
  27. const int N = 1e6+7;
  28. const int M = 1e3+3;
  29. const int MOD = 1e9+7;
  30. const int inf = 3e18;
  31.  
  32. bool check(int l, int r, string a){
  33. if(a[l] != a[r]) return false;
  34. if(l >= r) return true;
  35. return check(l+1, r-1, a);
  36. }
  37.  
  38. void solve(){
  39. string a;
  40. cin >> a;
  41. int n = a.size() - 1;
  42. if(check(0, n, a)) cout << "YES";
  43. else cout << "NO";
  44. }
  45.  
  46. signed main(){
  47. ios_base::sync_with_stdio(0);
  48. cin.tie(0);
  49. cout.tie(0);
  50. solve();
  51. }
  52.  
Success #stdin #stdout 0.01s 5288KB
stdin
Standard input is empty
stdout
YES