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

真要命,居然OLE

Posted by zyz at 2009-02-12 01:41:32 on Problem 2752
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

char input[400003];
int M[400003];
int res[400003];
int size;
int resize;

int main(){
	size = 0;  char c;
	while(scanf("%c", &c) && ((c<='z' && c>='a')||(c=='\n'))){
		if(c!='\n'){input[size++]=c;continue;}
		int k=0, resize = 0;
		for(int i=1; i<size; i++){
			while(k>0 && input[k]!=input[i]) k=M[k];
			if(input[k]==input[i]) k++;
			M[i] = k;  
		}
		k = M[size-1];  res[resize++] = size;
		while(k>0) {res[resize++] = k; k=M[k-1];}
		printf("%d", res[resize-1]);
		for(int i=resize-2; i>=0; i--)  printf(" %d", res[i]);  
		printf("\n");
		size = 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