Maruf_Hasan

D...Kanpur

Nov 24th, 2021
273
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.67 KB | None | 0 0
  1.  
  2.  
  3. #include<bits/stdc++.h>
  4. #include<ext/pb_ds/assoc_container.hpp>
  5. #include<ext/pb_ds/tree_policy.hpp>
  6.  
  7. using namespace std;
  8. using namespace __gnu_pbds;
  9.  
  10.  
  11.  
  12.  
  13.  
  14. #define pb push_back
  15. #define ll long long
  16. #define pii pair<int,int>
  17. #define pll pair<ll,ll>
  18. #define MaxN 201007
  19. #define INF 1e9
  20. #define INFL 1e18
  21. #define PI acos(-1)
  22. #define mp make_pair
  23.  
  24. typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
  25.  
  26. //const int fx[]= {+1,-1,+0,+0};
  27. //const int fy[]= {+0,+0,+1,-1};
  28. //const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1}; // Kings Move
  29. //const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1}; // Kings Move
  30. //const int fx[]={-2, -2, -1, -1, 1, 1, 2, 2}; // Knights Move
  31. //const int fy[]={-1, 1, -2, 2, -2, 2, -1, 1}; // Knights Move
  32.  
  33.  
  34. int gcd(int a, int b)
  35. {
  36. return b ? gcd(b, a%b) : a;
  37. }
  38.  
  39. ll bigmod(ll b,ll p,ll m)
  40. {
  41. ll res=1LL%m;
  42. ll x=b%m;
  43. while(p)
  44. {
  45. if( p & 1LL )res=(res*x) % m;
  46. x=(x*x)%m;
  47. p >>=1LL;
  48. }
  49. return res;
  50. }
  51.  
  52.  
  53.  
  54.  
  55. void blurryface()
  56. {
  57. int n;
  58. scanf("%d",&n);
  59. vector<int>v;
  60. int arr[n+100];
  61. for(int i=1;i<=n;i++)
  62. {
  63. int x;
  64. scanf("%d",&x);
  65. arr[i]=x;
  66. v.pb(x);
  67. // scanf("%d",&arr[i]);
  68. }
  69. sort(v.begin(),v.end());
  70. v.erase(unique(v.begin(),v.end()),v.end());
  71. for(int i=1;i<=n;i++)
  72. {
  73. arr[i]=upper_bound(v.begin(),v.end(),arr[i])-v.begin();
  74. }
  75. // for(int i=1;i<=n;i++)
  76. // {
  77. // cout<<arr[i]<<" ";
  78. // }
  79. // cout<<endl;
  80. // cout<<endl;
  81. if(n==1)
  82. {
  83. printf("YES\n");
  84. //cout<<"YES"<<endl;
  85. return;
  86. }
  87. else if(n==2)
  88. {
  89. if(arr[1]>arr[2])
  90. {
  91. printf("NO\n");
  92. // cout<<"NO"<<endl;
  93. }
  94. else
  95. {
  96. printf("YES\n");
  97. // cout<<"YES"<<endl;
  98. }
  99. return;
  100. }
  101. else
  102. {
  103. for(int i=1;i<=n;i++)
  104. {
  105. if((i%2)!=(arr[i]%2))
  106. {
  107. printf("NO\n");//<<endl;
  108. return;
  109. }
  110. }
  111. printf("YES\n");
  112. return;
  113. }
  114. }
  115.  
  116.  
  117. int main()
  118. {
  119.  
  120. // #ifndef ONLINE_JUDGE
  121. // freopen("input.txt","r",stdin);
  122. //freopen("output.txt","w",stdout);
  123. // #endif
  124. //ios_base::sync_with_stdio(false);
  125. //cin.tie(NULL);
  126. int t;
  127. scanf("%d",&t);
  128. while(t--)
  129. {
  130. blurryface();
  131. }
  132. //#ifdef LOCAL_DEFINE
  133. // cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
  134. // #endif
  135. ///Before submit=>
  136. /// *check for integer overflow,array bounds
  137. /// *check for n=1
  138. }
  139.  
  140.  
  141.  
  142.  
  143.  
  144.  
Advertisement
Add Comment
Please, Sign In to add comment