fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main(){
  5. freopen("HANDS.INP","r",stdin);
  6. freopen("HANDS.OUT","w",stdout);
  7. string s;
  8. int t=0,d=0,a=0;
  9. cin>>s;
  10. while(true){
  11. t++;
  12. a=0;
  13. for(int i=0;i<s.size();i++){
  14. if(s[i]=='R'&&s[i+1]=='L'){
  15. s[i]='L';
  16. s[i+1]='R';
  17. d++;
  18. a++;
  19. }
  20. }
  21. if(a==0){
  22. break;
  23. }
  24. }
  25. cout<<t<<" "<<d;
  26. }
  27.  
Success #stdin #stdout 0.01s 5276KB
stdin
RLLRLRR
stdout
Standard output is empty