fork download
  1. int t;
  2. cin>>t;
  3. while(t--)
  4. {
  5. int n;
  6. cin>>n;
  7. map<int,bool>m;
  8. vector<int>v;
  9.  
  10. for(int i=0;i<n;i++)
  11. {
  12. int x;
  13. cin>>x;
  14. v.push_back(x);
  15. }
  16. vector<int>copy;
  17.  
  18. for(int i=0;i<n;i++){
  19. int x=v[i];
  20.  
  21. while(i<n and x==v[i]){
  22. i++;
  23. }
  24. i--;
  25. copy.push_back(v[i]);
  26. }
  27. v=copy;
  28. // show(v);
  29.  
  30.  
  31. if(n==1){
  32. YES;
  33. continue;
  34. }
  35.  
  36. int c=0;
  37. n=v.size();
  38. if(n==1){
  39. NO;
  40. continue;
  41. }
  42. for(int i=0;i<n;i++)
  43. {
  44. if(i==0 and v[i]<v[i+1]){
  45. c++;
  46. }
  47. else if(i==n-1 and v[i]<v[i-1])c++;
  48. else if(i>0 and i<n-1)
  49. {
  50. if(v[i]<v[i+1] and v[i]<v[i-1])
  51. c++;
  52. }
  53.  
  54. /// if(c>1)break;
  55. }
  56.  
  57. if(c==0 or c>1)NO;
  58. else YES;
  59. //cout<<c<<endl;
  60. }
  61.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:2:6: error: ‘cin’ does not name a type
      cin>>t;
      ^~~
prog.cpp:3:6: error: expected unqualified-id before ‘while’
      while(t--)
      ^~~~~
stdout
Standard output is empty