fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. bool sq(vector<int> &a){
  4. int ver = a[0];
  5. for(int i = 1; i < a.size();i++){
  6. if(a[i] != ver) return false;
  7. }
  8. return true;
  9. }
  10. int main(){
  11. ios_base::sync_with_stdio(false);
  12. cin.tie(0);
  13. int t;
  14. cin >> t;
  15. while(t--){
  16. int n;
  17. cin >> n;
  18. vector<int> a(n);
  19. for(int &x : a) cin >> x;
  20. cout << (sq(a) ? "YES" : "NO");
  21. cout << "\n";
  22. }
  23. }
Success #stdin #stdout 0.01s 5288KB
stdin
7
1 2 3 4
1 1 1 1
2 2 2 2
1 2 1 2
1 1 5 5
5 5 5 5
4 10 5 9
stdout
YES
NO
YES
YES
NO
YES
YES