记录编号 293935 评测结果 AAAAAAAAAA
题目名称 [HZOI 2016]seq 最终得分 100
用户昵称 Gravatar洛克索耶夫 是否通过 通过
代码语言 C++ 运行时间 3.066 s
提交时间 2016-08-11 15:40:37 内存使用 14.15 MiB
显示代码纯文本
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;

int N, M, Q;
int seq[1010000], fa[1010000];
//fa[i]: 数字i最后被修改成的数值
int a[1010000], b[1010000];

inline int Read()
{
	int a = 0;
	char ch = getchar();
	while (ch < '0' || ch > '9')	ch = getchar();
	while (ch >= '0' && ch <= '9'){
		a = a*10 + ch-'0';
		ch = getchar();
	}
	return a;
}

int main()
{
	freopen("hzoi_seq.in", "r", stdin); freopen("hzoi_seq.out", "w", stdout);
	N = Read(); M = Read(); Q = Read();
	for(int i = 1; i <= N; i++)	seq[i] = Read();
	for(int i = 1; i <= M; i++)	fa[i] = i;
	for(int i = 1; i <= Q; i++)	a[i] = Read(), b[i] = Read();
	for(int i = Q; i >= 1; i--)	fa[a[i]] = fa[b[i]];
	for(int i = 1; i <= N; i++)	printf("%d ", fa[seq[i]]);
	//printf("%lf", (double)clock()/CLOCKS_PER_SEC);
	fclose(stdin); fclose(stdout);
	return 0;
}
/*		
*/