22672023-01-08 22:11:40nmarciUtazás (40)cpp11Wrong answer 14/40296ms63172 KiB
#include <bits/stdc++.h>

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

bool state[100100] = {false};

vector<int> g[100100];

int main()
{
  int n, m, q;
  cin >> n >> m >> q;
  vector<int> start(q);
  for(auto& i : start){
    cin >> i;
  }
  vector<bool> isjapan(n + 1, true);
  while(m--){
    int p, w;
    cin >> p >> w;
    g[w].push_back(p);
    isjapan[p] = false;
  }
  queue<int> bfs;
  for(int i = 1; i <= n; ++i){
    if(isjapan[i]){
      bfs.push(i);
    }
  }
  while(!bfs.empty()){
    auto p = bfs.front();
    bfs.pop();
    for(auto i : g[p]){
      bfs.push(i);
      if(!state[p]){
        state[i] = true;
      }
    }
  }
  for(auto i : start){
    if(state[i])
      cout << "A" << endl;
    else
      cout << "B" << endl;
  }
  return 0;
}
SubtaskSumTestVerdictTimeMemory
base14/40
1Accepted0/04ms6464 KiB
2Wrong answer0/085ms9940 KiB
3Accepted1/14ms7008 KiB
4Accepted2/24ms7096 KiB
5Accepted1/14ms7040 KiB
6Accepted2/2280ms44588 KiB
7Accepted2/219ms8448 KiB
8Accepted2/210ms7632 KiB
9Accepted2/219ms8608 KiB
10Accepted2/243ms10068 KiB
11Runtime error0/289ms60336 KiB
12Runtime error0/3103ms60932 KiB
13Runtime error0/3116ms61388 KiB
14Runtime error0/3142ms62980 KiB
15Runtime error0/3193ms61360 KiB
16Runtime error0/3296ms61852 KiB
17Runtime error0/3148ms61476 KiB
18Runtime error0/3170ms63172 KiB
19Runtime error0/3174ms63160 KiB