fork download
  1. //#include <ext/pb_ds/assoc_container.hpp>
  2. //#include <ext/pb_ds/tree_policy.hpp>
  3. //using namespace __gnu_pbds;
  4. //#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
  5. #include <bits/stdc++.h>
  6. using namespace std;
  7. #define int long long
  8. #define dd double
  9. #define ld long double
  10. #define ull unsigned long long
  11. #define yes cout << "YES\n"
  12. #define no cout << "NO\n"
  13. #define el "\n"
  14. #define Arwa ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  15. #define fix(x) cout << fixed << setprecision(x)
  16. #define all(v) v.begin(),v.end()
  17. void file()
  18. {
  19. #ifndef ONLINE_JUDGE
  20. freopen("input.txt", "r", stdin);
  21. freopen("output.txt", "w", stdout);
  22. #endif
  23. }
  24. int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
  25. int lcm(int a, int b) { return a / gcd(a, b) * b; }
  26. bool prime(int n) {
  27. if (n == 2) return true;
  28. if (n % 2 == 0 || n == 1) return false;
  29. for (int i = 3; i * i <= n; i += 2)
  30. if (n % i == 0) return false;
  31. return true;
  32. }
  33. //Here We Go Again
  34. int32_t main()
  35. {
  36. Arwa
  37. //file();
  38. int t=1;
  39. //cin>>t;
  40. while(t--)
  41. {
  42. string s;
  43. stack<int>st;
  44. map<int,int>m;
  45. vector<int>v,vv;
  46. cin>>s;
  47. for(int i=0;i<s.length();i++)
  48. {
  49. if(s[i]=='('||s[i]=='{'||s[i]=='['||s[i]=='<')
  50. st.push(i);
  51. else if(!st.empty())
  52. {
  53. if(s[i]==')'&&s[st.top()]=='(')
  54. st.pop();
  55. else if(s[i]=='}'&&s[st.top()]=='{')
  56. st.pop();
  57. else if(s[i]==']'&&s[st.top()]=='[')
  58. st.pop();
  59. else if(s[i]=='>'&&s[st.top()]=='<')
  60. st.pop();
  61. else v.push_back(i);
  62. }
  63. else v.push_back(i);
  64. }
  65. if(!st.empty())
  66. {
  67. while(!st.empty())
  68. {
  69. v.push_back(st.top());
  70. st.pop();
  71. }
  72. }
  73. //for(auto it:v) cout<<it<<' ';
  74. if(v.size())
  75. {
  76. sort(all(v)); //0
  77. for(int i=v.size()-1;i>0;i--)
  78. {
  79. if(v[i]-v[i-1]-1!=0)
  80. vv.push_back(v[i]-v[i-1]-1);
  81. }
  82. vv.push_back(s.size()-1-v[v.size()-1]);//2-0 2
  83. }
  84. else vv.push_back(s.length());
  85. for(auto it:vv)
  86. {
  87. cout<<it<<' ';
  88. m[it]++;
  89. }
  90. int max=0,mx=0;
  91. for(int i=0;i<vv.size();i++)
  92. {
  93. if(vv[i]>max)
  94. {
  95. mx=m[vv[i]];
  96. max=vv[i];
  97. }
  98. }
  99. if(max==0)
  100. cout<<0<<' '<<1<<el;
  101. else cout<<max<<' '<<mx<<el;
  102.  
  103. }
  104. return 0;
  105. }
  106. /*
  107.  
  108. */
  109.  
  110.  
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121.  
Success #stdin #stdout 0.01s 5276KB
stdin
Standard input is empty
stdout
0 0 1