fork download
  1. // Problem :
  2.  
  3. #pragma GCC optimize("Ofast,unroll-loops,inline,fast-math")
  4. #pragma GCC target("avx2,sse4.2,bmi,bmi2,lzcnt,popcnt,fma")
  5.  
  6. #include <bits/stdc++.h>
  7.  
  8. #if LOCAL
  9. #include "algo/debug.h"
  10. #endif
  11.  
  12. #define task "sol"
  13.  
  14. using namespace std;
  15. using ll = long long;
  16.  
  17. constexpr int MOD = 1e9 + 7;
  18. constexpr int LIMIT = 1e6 + 7;
  19. constexpr ll INF = LLONG_MAX;
  20.  
  21. signed main() {
  22. ios_base::sync_with_stdio(false);
  23. cin.tie(nullptr); cout.tie(nullptr);
  24.  
  25. if (fopen(task".inp", "r")) {
  26. freopen(task".inp", "r", stdin), freopen(task".out", "w", stdout);
  27. }
  28.  
  29. string s;
  30. cin >> s;
  31.  
  32. int n = s.size();
  33.  
  34. vector<int> suff(n + 1, 0);
  35.  
  36. for (int i = n - 1; i >= 0; --i) {
  37. suff[i] = suff[i + 1] + (s[i] == 'L');
  38. }
  39.  
  40. int cnt = 0, shakes = 0, rounds = 0;
  41.  
  42. for (char c : s) {
  43. if (c == 'R') {
  44. ++cnt;
  45. } else {
  46. shakes += cnt;
  47. }
  48. }
  49.  
  50. for (int i = 0; i < n; ++i) {
  51. if (s[i] == 'R') {
  52. rounds = max(rounds, suff[i]);
  53. }
  54. }
  55.  
  56. cout << rounds << ' ' << shakes << '\n';
  57.  
  58. return 0;
  59. }
  60.  
Success #stdin #stdout 0.01s 5320KB
stdin
Standard input is empty
stdout
0 0