fork download
  1. #define _CRT_SECURE_NO_WARNINGS
  2.  
  3. #include <bits/stdc++.h>
  4. using namespace std;
  5.  
  6. typedef long long ll;
  7. typedef long double ld;
  8. typedef unsigned long long ull;
  9. typedef pair<int, int> pii;
  10. typedef pair<ll, ll> pll;
  11. typedef vector<int> vi;
  12. typedef vector<vi> vvi;
  13.  
  14. #define sc(x) scanf("%d", &x)
  15. #define sc2(x, y) scanf("%d%d", &x, &y)
  16. #define sc3(x, y, z) scanf("%d%d%d", &x, &y, &z)
  17. #define sc4(x, y, z, t) scanf("%d%d%d%d", &x, &y, &z, &t)
  18. #define print(x) printf("%d ", x)
  19. #define println(x) printf("%d\n", x)
  20. #define println2(x, y) printf("%d %d\n", x, y)
  21. #define println3(x, y, z) printf("%d %d %d\n", x, y, z)
  22. #define println4(x, y, z, t) printf("%d %d %d %d\n", x, y, z, t)
  23. #define mp make_pair
  24. #define pb push_back
  25. #define ft first
  26. #define sd second
  27. #define sz(x) (int)x.size()
  28. #define all(x) x.begin(), x.end()
  29. #define endl '\n' // CommentInInteractive
  30. #define DB(x) cerr << #x << " = " << x << endl
  31.  
  32. const ld eps = 1e-6;
  33. const int inf = INT_MAX;
  34. const ll INF = LLONG_MAX;
  35.  
  36. void solve() {
  37. string s;
  38. cin >> s;
  39. int n = sz(s);
  40. cout << "Input string [" << s << "], length = " << n << endl;
  41. if (n == 0) {
  42. cout << "No input" << endl; return;
  43. }
  44.  
  45. vector<int> dp(n,0);
  46. dp[0] = (s[0] == 'L');
  47. int ans = (s[0] == 'L');
  48. for (int i = 1; i < n; i++) {
  49. if (s[i] == 'L') {
  50. dp[i] = dp[i - 1] + 1;
  51. ans = max(ans, dp[i]);
  52. }
  53. }
  54. cout << ans + 1 << endl;
  55. }
  56.  
  57. //#define FILES
  58. //#define TIME
  59.  
  60. int main() {
  61. ios_base::sync_with_stdio(false);
  62. cin.tie(nullptr); cout.tie(nullptr);
  63.  
  64. #ifdef FILES
  65. freopen("input.txt", "r", stdin);
  66. // freopen("output.txt", "w", stdout);
  67. #endif
  68.  
  69. auto start = chrono::high_resolution_clock::now();
  70. int t; sc(t);
  71. while (t--) solve();
  72. auto stop = chrono::high_resolution_clock::now();
  73.  
  74. #ifdef TIME
  75. cerr << chrono::duration_cast <chrono::milliseconds> (stop - start).count() << " ms\n";
  76. #endif
  77. return 0;
  78. }
Success #stdin #stdout 0s 4312KB
stdin
6
LRLRRLL
L
LLR
RRRR
LLLLLL
R
stdout
Input string [], length = 0
No input
Input string [], length = 0
No input
Input string [], length = 0
No input
Input string [], length = 0
No input
Input string [], length = 0
No input
Input string [], length = 0
No input