3058.txt

来自「北大ACM题目例程 详细的解答过程 程序实现 算法分析」· 文本 代码 · 共 69 行

TXT
69
字号
Source

Problem Id:3058  User Id:fzk 
Memory:3988K  Time:593MS
Language:G++  Result:Accepted

Source 

#include <stdio.h>
#include <algorithm>
#include <memory.h>
using namespace std;

int w1[1000000];


int main() {
	int t, i, j, m;
	char c, temp;

	scanf( "%d", &t );
	getchar();

	while( t-- ) {

		m = 0;

		while( 1 ){
			c = getchar();
			
			if( c == '\n' )
				break;
			
			if( c >= '0' && c <= '9' ) {
				j = 0;
				while( c >= '0' && c <= '9' ) {
					j = j*10 + c-'0';
					c = getchar();
				}
				while( --j ) {
					w1[m] = (temp<<20)|m;
					m++;
				}

				ungetc( c, stdin );
			}
			else {
				w1[m] = (c<<20)|m;
				m++;
			}

			temp = c;
		}

	
		sort( w1, w1+m );

		for( j = (w1[0]&((1<<20)-1)), i=0; i<m; i++ ) {
			printf( "%c", w1[j]>>20 );
			j = (w1[j]&((1<<20)-1));
		}
		printf( "\n" );

	}
	return 0;
}


⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?