Guest User

Untitled

a guest
Apr 25th, 2020
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.71 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. #define lld long long
  3. #define pb push_back
  4. #define mk make_pair
  5. #define MAX 1000000
  6. using namespace std;
  7. int main()
  8. {
  9.     #ifndef ONLINE_JUDGE
  10.     // for getting input from input.txt
  11.     freopen("input.txt", "r", stdin);
  12.     // for writing output to output.txt
  13.     freopen("output.txt", "w", stdout);
  14.     #endif
  15.  
  16.     lld t;
  17.     cin>>t;
  18.  
  19.     while(t--)
  20.     {
  21.         lld n,k,x;
  22.         cin>>n>>k;
  23.         std::vector<pair<lld,lld>> v;
  24.  
  25.         for(lld i=0;i<n;i++)
  26.         {
  27.             cin>>x;
  28.             v.pb(mk(x,i));
  29.         }
  30.  
  31.         lld flag=0;
  32.  
  33.         sort(v.begin(), v.end());
  34.  
  35.         for(lld i=0;i<n;i++)
  36.         {
  37.             if(((v[i].second)%k)!= (i%k))
  38.             {
  39.                 flag=1;
  40.                 break;
  41.             }
  42.         }
  43.  
  44.         if(flag)
  45.             cout<<"no"<<endl;
  46.         else
  47.             cout<<"yes"<<endl;
  48.  
  49.     }
  50. }
Add Comment
Please, Sign In to add comment