22692023-01-08 22:26:24nmarciUtazás (40)cpp11Accepted 40/40125ms11264 KiB
#include <bits/stdc++.h>

using namespace std;
using ll = long long int;
const ll inf = 1e9;

bool state[100100] = {false};
bool done[100100] = {false};
vector<int> g[100100];

void dfs(int node){
  if(done[node]) return;
  done[node] = true;
  for(auto i : g[node]){
    dfs(i);
    if(!state[i])
      state[node] = true;
  }
}

int main()
{
  int n, m, q;
  cin >> n >> m >> q;
  vector<int> start(q);
  for(auto& i : start){
    cin >> i;
  }
  while(m--){
    int p, w;
    cin >> p >> w;
    g[p].push_back(w);
  }
  for(int i = 1; i <= n; ++i){
    if(!done[i]){
      dfs(i);
    }
  }
  for(auto i : start){
    if(state[i])
      cout << "A" << endl;
    else
      cout << "B" << endl;
  }
  return 0;
}
SubtaskSumTestVerdictTimeMemory
base40/40
1Accepted0/04ms6596 KiB
2Accepted0/079ms9436 KiB
3Accepted1/14ms6996 KiB
4Accepted2/24ms6944 KiB
5Accepted1/14ms7200 KiB
6Accepted2/24ms7412 KiB
7Accepted2/27ms7660 KiB
8Accepted2/29ms8136 KiB
9Accepted2/26ms8124 KiB
10Accepted2/28ms8252 KiB
11Accepted2/232ms8812 KiB
12Accepted3/332ms8860 KiB
13Accepted3/335ms9040 KiB
14Accepted3/335ms9160 KiB
15Accepted3/335ms9252 KiB
16Accepted3/337ms9148 KiB
17Accepted3/364ms9924 KiB
18Accepted3/3125ms11256 KiB
19Accepted3/3125ms11264 KiB