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 <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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator