Advertisement
sacgajcvs

Untitled

Jul 26th, 2019
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.92 KB | None | 0 0
  1. /*
  2. _____ _ _ _ _
  3. |_ _| |__ ___ / \ _ __ ___| |__ _ _| |
  4. | | | '_ \ / _ \ / _ \ | '_ \/ __| '_ \| | | | |
  5. | | | | | | __// ___ \| | | \__ \ | | | |_| | |
  6. |_| |_| |_|\___/_/ \_\_| |_|___/_| |_|\__,_|_|
  7.  
  8. */
  9. #include<bits/stdc++.h>
  10. #define ll long long
  11. #define pb push_back
  12. #define ppb pop_back
  13. #define endl '\n'
  14. #define mii map<ll int,ll int>
  15. #define msi map<string,ll int>
  16. #define mis map<ll int, string>
  17. #define rep(i,a,b) for(ll int i=a;i<b;i++)
  18. #define mpi map<pair<ll int,ll int>,ll int>
  19. #define pii pair<ll int,ll int>
  20. #define vi vector<ll int>
  21. #define vii vector<pair<ll int, ll int>>
  22. #define vs vector<string>
  23. #define all(a) (a).begin(),(a).end()
  24. #define F first
  25. #define S second
  26. #define sz(x) (ll int)x.size()
  27. #define hell 1000000007
  28. #define lbnd lower_bound
  29. #define ubnd upper_bound
  30. #define bs binary_search
  31. #define mp make_pair
  32. #define what_is(x) cerr << #x << " is " << x << endl;
  33. #define time cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
  34. using namespace std;
  35. #define N 100005
  36.  
  37. void solve()
  38. {
  39. ll k,n;
  40. string s;
  41. cin>>s;
  42. n=s.length();
  43. cin>>k;
  44. ll cnt=1;
  45. string ans="";
  46. char c=s[0];
  47. rep(i,1,n)
  48. {
  49. if(s[i]!=c)
  50. {
  51. if(cnt<k)
  52. {
  53. rep(j,0,cnt)
  54. ans+=c;
  55. }
  56. cnt=1;
  57. c=s[i];
  58. }
  59. else
  60. cnt++;
  61. }
  62. if(cnt<k)
  63. {
  64. rep(j,0,cnt)
  65. ans+=c;
  66. }
  67. cout<<ans;
  68. return;
  69. }
  70. int main()
  71. {
  72. ios_base::sync_with_stdio(false);
  73. cin.tie(0);
  74. cout.tie(0);
  75. int TESTS=1;
  76. // cin>>TESTS;
  77. while(TESTS--)
  78. {
  79. solve();
  80. }
  81. time
  82. return 0;
  83. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement