66842023-12-16 14:08:08111Utazás (40)cpp17Elfogadva 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;
}
RészfeladatÖsszpontTesztVerdiktIdőMemória
base40/40
1Elfogadva0/03ms1832 KiB
2Elfogadva0/041ms9760 KiB
3Elfogadva1/13ms2264 KiB
4Elfogadva2/23ms2336 KiB
5Elfogadva1/13ms2464 KiB
6Elfogadva2/23ms2548 KiB
7Elfogadva2/24ms2784 KiB
8Elfogadva2/26ms3704 KiB
9Elfogadva2/24ms3308 KiB
10Elfogadva2/26ms3688 KiB
11Elfogadva2/214ms4916 KiB
12Elfogadva3/316ms5332 KiB
13Elfogadva3/316ms5404 KiB
14Elfogadva3/316ms5536 KiB
15Elfogadva3/317ms5520 KiB
16Elfogadva3/317ms5636 KiB
17Elfogadva3/329ms7484 KiB
18Elfogadva3/352ms10288 KiB
19Elfogadva3/354ms10284 KiB