Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- #define lld long long
- #define pb push_back
- #define mk make_pair
- #define MAX 1000000
- using namespace std;
- int main()
- {
- #ifndef ONLINE_JUDGE
- // for getting input from input.txt
- freopen("input.txt", "r", stdin);
- // for writing output to output.txt
- freopen("output.txt", "w", stdout);
- #endif
- lld t;
- cin>>t;
- while(t--)
- {
- lld n,k,x;
- cin>>n>>k;
- std::vector<pair<lld,lld>> v;
- for(lld i=0;i<n;i++)
- {
- cin>>x;
- v.pb(mk(x,i));
- }
- lld flag=0;
- sort(v.begin(), v.end());
- for(lld i=0;i<n;i++)
- {
- if(((v[i].second)%k)!= (i%k))
- {
- flag=1;
- break;
- }
- }
- if(flag)
- cout<<"no"<<endl;
- else
- cout<<"yes"<<endl;
- }
- }
Add Comment
Please, Sign In to add comment