Guest User

Untitled

a guest
Apr 25th, 2020
43
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include<bits/stdc++.h>
  2. #define fast cin.tie(0);cout.tie(0); ios_base::sync_with_stdio(0);
  3. #define mod 1000000007
  4. #define vi vector<ll>
  5. typedef long long int ll;
  6.  
  7. using namespace std;
  8. int main()
  9. {
  10. int t,k,n;
  11. cin >> t;
  12. while(t--){
  13. cin >> n >> k ;
  14. vi a(n),b(n);
  15. int f = 0;
  16. for(int i = 0 ; i < n ; i ++) {
  17. cin >> a[i];
  18. b[i] = a[i];
  19. }
  20. sort(b.begin(),b.end());
  21. map<ll,ll> v;
  22. for(int i = 0; i < n ; i ++){
  23. auto l = lower_bound(b.begin(), b.end(), a[i]) - b.begin();
  24. //cout << a[i] <<" "<<l <<"\n";
  25. if((i)%k != (int(l)+v[a[i]])% k )
  26. {
  27. f = 1;
  28. break;
  29. }
  30. v[a[i]]++;
  31. cout <<a[i] <<" " << v[a[i]] <<"\n";
  32. }
  33. if(f == 0 )
  34. cout <<"yes\n";
  35. else
  36. cout <<"no\n";
  37.  
  38.  
  39. }}
RAW Paste Data