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 00448162 at 2005-05-11 22:35:36 on Problem 1026
#include <iostream>
#include <string>

using namespace std;

void main()
{
	int i = 0, j = 0, len = 0, n = 0, size = 0;
	string temp1, temp2, message;
	int key[200] = { 0 };

	while( 1 )
	{
		cin>> len;
		if( len == 0 )
			break;

		for( i = 0; i < len; i ++ )
			cin>> key[i];
		
		while( 1 )
		{
			cin>> n;
			if( n == 0 )
				break;

			cin.ignore();
			getline( cin, message );
			size = message.size();
			message.resize( message.length() + len - size );
			for( i = size; i < len; i ++ )
				message.at( i ) = ' ';

			temp1.assign( message );
			temp2.assign( message );
			for( j = 1; j <= n; j ++ )
			{
				for( i = 0; i < len; i ++ )
					temp2.at( key[i] - 1 ) = temp1.at( i );
				
				temp1.assign( temp2 );

				if( temp1 == message )
				{
					n = n % j;
					temp1.assign( message );
					j = 0;
				}
			}

			cout<< temp2<< endl;
		}
	}
}


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