66832023-12-16 14:02:23111Utazás (40)cpp17Wrong answer 17/4052ms10628 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;
		}
		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
base17/40
1Accepted0/03ms1836 KiB
2Wrong answer0/041ms10628 KiB
3Accepted1/13ms2132 KiB
4Accepted2/23ms2340 KiB
5Accepted1/13ms2560 KiB
6Accepted2/23ms2696 KiB
7Accepted2/24ms2892 KiB
8Accepted2/26ms3716 KiB
9Accepted2/24ms3184 KiB
10Accepted2/26ms3372 KiB
11Wrong answer0/214ms4728 KiB
12Accepted3/316ms4904 KiB
13Wrong answer0/316ms5088 KiB
14Wrong answer0/316ms5100 KiB
15Wrong answer0/317ms5296 KiB
16Wrong answer0/317ms5400 KiB
17Wrong answer0/329ms7148 KiB
18Wrong answer0/352ms9832 KiB
19Wrong answer0/352ms9908 KiB