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

WHY PE!!提交了N次就是PE

Posted by heiheigo at 2005-05-23 19:31:01 on Problem 2255
#include "stdio.h"
#include "string.h"
main()
{
char a[50],b[50];
int len,i,j;
int d=0,n,m,sv=0;
int red,kao;
int gg=1;
while(scanf("%s%s",&a,&b)!=EOF){
     len=strlen(a);
	 while(b[0]!=a[sv]) sv++;
	 if(sv==0) sv++;
	 red=0;
	 for(i=1;i<len;i++){
	   if(b[i]!=a[sv-1]){
		while(b[i]!=a[d]&&d<len) d++;
		m=d-1;
		n=d+1;
		while(a[n]==' '&&n<len) n++;
		while(a[m]==' '&&m>=1) m--;
		if(b[i+1]==a[n]&&(i+1)<len){
		kao=i;
while(b[kao+1+gg]==a[n+gg]&&(kao+gg+1)<len){
			a[n+gg]=' ';
			gg++;
			i++;
			}
		while(gg>1){
			if((kao+gg)<len)
			printf("%c",b[kao+gg]);
			b[kao+gg]=' ';
			gg--;}
		gg=1;
		printf("%c",b[kao+1]);
	printf("%c",b[kao]);
	a[n]=b[kao+1]=' ';a[d]=b[kao]=' ';i++;}
	if(b[i+1]==a[m]&&(i+1)<len){
		printf("%c",b[i]);
		a[d]=b[i]=' ';}
}
	else{
		for(j=i-1;j>red;j--)
		 if(b[j]!=' '){
			 printf("%c",b[j]);
				while(b[j]!=a[d]) d++;
				b[j]=' ';
			    a[d]=' ';
					 }
		printf("%c",a[sv]);
		a[sv]=' ';
		red=i;
		if(sv-1>0) sv--;
			 }
  d=0;n=m=1;
	 }
	 for(j=i-1;j>red;j--)
		 if(b[j]!=' '){
		  printf("%c",b[j]);
		while(b[i]!=a[d]) d++;
	    a[d]=' ';
					 }
		 printf("%c\n",a[0]);
	 	 d=0;n=m=1;sv=0;gg=1;
}
}



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