#include<iostream>
#include<cstdio>
#include<string.h>
#include<string>
#include<cstring>
#include<algorithm>
#include<stack>
#include<map>
using namespace std;
const int maxn = 1000050;
char input[maxn];
bool mark[maxn];
int getmax(int a, int b){
return a > b? a: b;
}
int main(){
memset(input, 0, sizeof(input));
while(cin >> input){
stack<int> astack;
memset(mark, 0, sizeof(mark));
map<int,int>recmap;
int len = strlen(input);
for(int i = 0; i < len; ++i){
if(input[i] == '('){
astack.push(i);
}
else if(input[i] == ')'){
if(!astack.empty()){
int idx = astack.top();
astack.pop();
mark[idx] = mark[i] = true;
}
}
}
int maxlen = -1, cnt = 0, index = 0;
while(true){
cnt = 0;
while(index < len && mark[index] == true){
++cnt;
++index;
}
maxlen = getmax(maxlen, cnt);
recmap[cnt]++;
if(index >= len){
break;
}
++index;
}
if(maxlen == -1 || maxlen == 0){
cout << "0 1\n";
}
else{
cout << maxlen << " " << recmap[maxlen] << endl;
}
memset(input, 0, sizeof(input));
}
return 0;
}
转载于:https://my.oschina.net/u/1421373/blog/379439