mirror of
https://github.com/Kiritow/OJ-Problems-Source.git
synced 2024-03-22 13:11:29 +08:00
Create 11488_zhouworld16.cpp
This commit is contained in:
parent
55e3cf89b6
commit
4faf133ea3
46
UVA/11488_zhouworld16.cpp
Normal file
46
UVA/11488_zhouworld16.cpp
Normal file
|
@ -0,0 +1,46 @@
|
|||
#include <iostream>
|
||||
#include <cstring>
|
||||
#include <string>
|
||||
#include <cstdio>
|
||||
using namespace std;
|
||||
|
||||
const int maxn=500000;
|
||||
int tree[maxn][2];
|
||||
int val[maxn],cnt;
|
||||
int n,ans;
|
||||
|
||||
void insert(string st){
|
||||
int s=0;
|
||||
for(int i=0;i<st.length();i++){
|
||||
if( tree[s][st[i]-'0']==0 ) tree[s][st[i]-'0']=++cnt;
|
||||
s=tree[s][st[i]-'0'];
|
||||
val[s]++;
|
||||
if((i+1)*val[s]>ans) ans=(i+1)*val[s];
|
||||
}
|
||||
}
|
||||
|
||||
void initial(){
|
||||
cnt=ans=0;
|
||||
memset(val,0,sizeof(val));
|
||||
memset(tree,0,sizeof(tree));
|
||||
}
|
||||
|
||||
void solve(){
|
||||
cin>>n;
|
||||
for(int i=0;i<n;i++){
|
||||
string st;
|
||||
cin>>st;
|
||||
insert(st);
|
||||
}
|
||||
cout<<ans<<endl;
|
||||
}
|
||||
|
||||
int main(){
|
||||
int t;
|
||||
cin>>t;
|
||||
while(t-- >0){
|
||||
initial();
|
||||
solve();
|
||||
}
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user