Advertisement
a53

SeqCuts

a53
Apr 23rd, 2022
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. #include <iostream>
  2. #include <queue>
  3. #include <vector>
  4. #include <algorithm>
  5. #include <stack>
  6.  
  7. using namespace std;
  8. #define Inf 0x3f3f3f3f
  9. #define mod 1e9+7
  10.  
  11. char a[2000005];
  12. int n,k,l;
  13. char s[2000005];
  14.  
  15. int main(){
  16.  
  17. ios::sync_with_stdio(false);
  18. cin.tie(0);
  19. cout.tie(0);
  20. cin >> n >> k >> l;
  21. cin >> a;
  22. int dr = 0;
  23. for(int i = 0 ; i < n ; ++i){
  24.  
  25. while(dr >= l && k && a[i] < s[dr - l]){
  26. dr = dr - l;
  27.  
  28. k--;
  29. }
  30. s[dr++] = a[i];
  31. if(k == 0){
  32. int j = i + 1;
  33. while(j < n)
  34. s[dr++] = a[j++];
  35.  
  36. break;
  37. }
  38. }
  39. if(k)
  40. dr = dr - k * l;
  41.  
  42. s[dr] = '\0';
  43. cout << s;
  44.  
  45.  
  46. return 0;
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement