http://poj.org/problem?id=3007
第一次用STL做的,TLE了,自己构造字符串哈希函数才可以。。
TLE代码:
1 #include <cstdio> 2 #include <algorithm> 3 #include <iostream> 4 #include <string> 5 #include <map> 6 using namespace std; 7 int main() 8 { 9 int n; 10 scanf("%d",&n); 11 while(n--) 12 { 13 int cnt = 0,j; 14 char ss[120]; 15 string str,s,s1,s2; 16 map<string,int>v; 17 cin>>str; 18 s = str; 19 int len = str.size(); 20 21 for (int i = 1; i < len; i++) 22 { 23 s = str; 24 string::iterator it = s.begin(); 25 for (j = 0; j < i; j++) 26 ss[j] = str[j]; 27 ss[j] = '