fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define int long long
  4. #define endl '\n'
  5. const int mod = 1e9+7;
  6. #define yes cout << "Yes" << endl;
  7. #define no cout << "No" << endl;
  8.  
  9. // inv b = mod-2
  10.  
  11. int binpow(int a, int b)
  12. {
  13. int res = 1;
  14. a = a % mod;
  15. while (b != 0)
  16. {
  17. if (b & 1)
  18. {
  19. res = (res * a) % mod;
  20. }
  21. a = (a * a) % mod;
  22. b = b >> 1;
  23. }
  24. return res;
  25. }
  26.  
  27. void solve()
  28. {
  29. string s;
  30. cin>>s;
  31. int n = s.length();
  32.  
  33. vector<int> cnt(n,0);
  34. int last = -1;
  35. for(int i=n-1;i>=0;i--){
  36. if(s[i]=='L'){
  37. last = i;
  38. }
  39. else{
  40. int kk = (last-i);
  41. if(kk%2){
  42. cnt[last-1]++;
  43. }
  44. else{
  45. cnt[last]++;
  46. }
  47. }
  48. }
  49.  
  50. for(int i=0;i<n;i++){
  51. if(s[i]=='R'){
  52. last = i;
  53. }
  54. else{
  55. int kk = (i-last);
  56. if(kk%2){
  57. cnt[last+1]++;
  58. }
  59. else{
  60. cnt[last]++;
  61. }
  62. }
  63. }
  64.  
  65. for(int i=0;i<n;i++){
  66. cout<<cnt[i];
  67. }
  68. cout<<endl;
  69.  
  70. return;
  71. }
  72.  
  73. signed main()
  74. {
  75. ios::sync_with_stdio(false);
  76. cout.tie(0);
  77. cin.tie(0);
  78. int t = 1;
  79. cin >> t;
  80. while (t-- != 0)
  81. {
  82.  
  83. solve();
  84. }
  85. return 0;
  86. }
Success #stdin #stdout 0.01s 5280KB
stdin
Standard input is empty
stdout