fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. int t;
  6. cin>>t;
  7. while(t--){
  8. int w;
  9. cin>>w;
  10. bool res = true;
  11. if(w%2 == 0){
  12. res = false;
  13. }
  14. int i = 1;
  15. int c = w;
  16.  
  17. while(c--){
  18. int h;
  19. cin>>h;
  20. if(c*2>w){
  21. if(h!=i++) {
  22. res = false;
  23. }}
  24. else{
  25. if(h!=i--) {
  26. res = false;
  27. }}
  28. }
  29. if(res) cout<<"yes\n";
  30. else cout<<"no\n";
  31. }
  32. return 0;
  33. }
Success #stdin #stdout 0s 16048KB
stdin
7
5
1 2 3 2 1
7
2 3 4 5 4 3 2
5
1 2 3 4 3
5
1 3 5 3 1
7
1 2 3 4 3 2 1
4
1 2 3 2
4
1 2 2 1
stdout
yes
no
no
no
yes
no
no