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<char>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. }
  62. else v.push_back(i);
  63. }
  64. if(!st.empty())
  65. {
  66. while(!st.empty())
  67. {
  68. v.push_back(st.top());
  69. st.pop();
  70. }
  71. }
  72. if(v.size())
  73. {
  74. sort(all(v));
  75. //for(auto it:v)
  76. //cout<<it<<' ';
  77. //cout<<el;
  78. for(int i=v.size()-1;i>0;i--)
  79. {
  80. if(v[i]-v[i-1]-1!=0)
  81. vv.push_back(v[i]-v[i-1]-1);
  82. }
  83. vv.push_back(s.size()-1-v[v.size()-1]);
  84. }
  85. else vv.push_back(s.length());
  86. for(auto it:vv)
  87. {
  88. //cout<<it<<' ';
  89. if(it!=0)
  90. m[it]++;
  91. }
  92. int max=0,mx=0;
  93. for(int i=0;i<vv.size();i++)
  94. {
  95. if(vv[i]>max)
  96. {
  97. mx=m[vv[i]];
  98. max=vv[i];
  99. }
  100. }
  101. if(mx==0)
  102. cout<<0<<' '<<1<<el;
  103. else cout<<max<<' '<<mx<<el;
  104.  
  105. }
  106. return 0;
  107. }
  108.  
  109.  
  110.  
Success #stdin #stdout 0s 5264KB
stdin
Standard input is empty
stdout
0 1