66842023-12-16 14:08:08111Utazás (40)cpp17Accepted 40/4054ms10288 KiB
#include <bits/stdc++.h>
using namespace std;

#define int long long
#define double long double

#define pii pair<int, int>

signed main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
#ifdef CB
	freopen("be2.txt", "r", stdin);
//	freopen("out.txt", "w", stdout);
#endif
	int N, M, Q;
	cin >> N >> M >> Q;
	vector<int> q(Q);
	for (int i = 0; i < Q; i++) {
		cin >> q[i];
	}
	vector<vector<int>> g(N + 1);
	vector<int> c(N + 1);
	for (int i = 0; i < M; i++) {
		int a, b;
		cin >> a >> b;
		g[a].push_back(b);
		c[b]++;
	}
	vector<int> s;
	auto dfs = [&](auto dfs, int i) {
		if (c[i]) {
			return;
		}
		c[i]--;
		s.push_back(i);
		for (int j : g[i]) {
			c[j]--;
			dfs(dfs, j);
		}
	};
	for (int i = 1; i <= N; i++) {
		dfs(dfs, i);
	}
	reverse(s.begin(), s.end());
	vector<char> a(N + 1);
	for (int i : s) {
		a[i] = 'B';
		for (int j : g[i]) {
			if (a[j] == 'B') {
				a[i] = 'A';
			}
		}
	}
	for (int i : q) {
		cout << a[i] << '\n';
	}
	return 0;
}
SubtaskSumTestVerdictTimeMemory
base40/40
1Accepted0/03ms1832 KiB
2Accepted0/041ms9760 KiB
3Accepted1/13ms2264 KiB
4Accepted2/23ms2336 KiB
5Accepted1/13ms2464 KiB
6Accepted2/23ms2548 KiB
7Accepted2/24ms2784 KiB
8Accepted2/26ms3704 KiB
9Accepted2/24ms3308 KiB
10Accepted2/26ms3688 KiB
11Accepted2/214ms4916 KiB
12Accepted3/316ms5332 KiB
13Accepted3/316ms5404 KiB
14Accepted3/316ms5536 KiB
15Accepted3/317ms5520 KiB
16Accepted3/317ms5636 KiB
17Accepted3/329ms7484 KiB
18Accepted3/352ms10288 KiB
19Accepted3/354ms10284 KiB