Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

居然超时,线性的都能超时,大神,解答一下

Posted by gxn at 2018-08-13 19:07:08 on Problem 2752
#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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator