| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
居然超时,线性的都能超时,大神,解答一下#include<cstdio>
#include<iostream>
#include<cstring>
#include<string>
using namespace std;
const int maxn = 400005;
int num[maxn];
int main()
{
string s;
while(cin >> s){
int cnt = s.length();
int ans = 0;
for(int i = 1; i <= s.length(); i++){
string s_front = s.substr(0, i);
string s_end = s.substr(s.length() - i, s.length());
if(s_front == s_end) printf("%d ", i);
//cout << s_front << " " << s_end << endl;
}
printf("\n");
}
return 0;
}
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator