usingnamespace std; #define fast \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); constint N = 1e3 + 10; constint M = 1e6 + 10; constint INF = 0x3f3f3f3f; constlonglong LINF = 0x3f3f3f3f3f3f3f3f; constint mod = 1e9 + 7; constdouble eps = 1e-3; set<int> up[N]; int age[N]; int vis[N]; int id1[N], id2[N]; intbfs(int x){ memset(vis, 0, sizeof vis); queue<int> q; q.push(x); int res = INF; while (!q.empty()) { int u = q.front(); q.pop(); for (auto it : up[u]) { if (vis[it]) continue; q.push(it); vis[it] = 1; //通过位置找到现在在这个位置上的编号,并更新最小年龄 res = min(res, age[id1[it]]); } } return res; } intmain(){ int n, m, I; cin >> n >> m >> I; for (int i = 1; i <= n; i++) { id1[i] = i; id2[i] = i; } for (int i = 1; i <= n; i++) scanf("%d", &age[i]); for (int i = 1; i <= m; i++) { int x, y; scanf("%d%d", &x, &y); up[y].insert(x); } for (int i = 1; i <= I; i++) { char o[2]; scanf("%s", o); if (o[0] == 'T') { int x, y; scanf("%d%d", &x, &y); // 交换编号x和y所在位置的编号,并交换编号x和y的所在位置 swap(id1[id2[x]], id1[id2[y]]); swap(id2[x], id2[y]); } else { int x; scanf("%d", &x); // 找到编号x的现在位置 x = id2[x]; int w = bfs(x); if (w == INF) puts("*"); else printf("%d\n", w); } } return0; }