Advertisement
sherry_ahmos

Untitled

Mar 18th, 2022
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.70 KB | None | 0 0
  1. #include <iostream>
  2. #include <sstream>
  3. #include <cstdlib>
  4. #include <algorithm>
  5. #include <cmath>
  6. #include <iomanip>
  7.  
  8. using namespace std;
  9. #define ll long long
  10. void sherry()
  11. {
  12.     ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
  13. #ifndef ONLINE_JUDGE
  14.     freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout);
  15. #endif
  16. }
  17.  
  18. ll n;
  19. ll i = 0;
  20. ll recursion(ll arr[], ll i)
  21. {
  22.     if (n == i)
  23.         return 1;
  24.     return arr[i] == arr[n - i - 1] && recursion(arr, i + 1);
  25. }
  26. int main()
  27. {
  28.     sherry();
  29.     cin >> n;
  30.     ll arr[n];
  31.     for (int i = 0; i < n; i++)
  32.         cin >> arr[i];
  33.     recursion( arr, i) ? cout << "YES" : cout << "NO";
  34.     return 0;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement