fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5. ios_base::sync_with_stdio(false);
  6. cin.tie(0);
  7.  
  8. int t;
  9. cin >> t;
  10. while (t--) {
  11. int n;
  12. cin >> n;
  13. vector<int> a(n);
  14. for (int i = 0; i < n; i++) {
  15. cin >> a[i];
  16. }
  17. bool check = true;
  18. for (int i = 0; i < n / 2; i++) {
  19. if (a[i] != a[n - i - 1]) {
  20. check = false;
  21. break;
  22. }
  23. }
  24. if(check)
  25. cout << "YES" << endl;
  26. else
  27. cout << "NO" << endl;
  28. a[n] = 0;
  29. }
  30. return 0;
  31. }
  32.  
Success #stdin #stdout 0s 5288KB
stdin
2
1
1 4 4 1
5
1 5 5 5 3
stdout
YES
NO