22682023-01-08 22:15:48nmarciUtazás (40)cpp11Wrong answer 14/40289ms63216 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];
vector<bool> isjapan;
int main()
{
  int n, m, q;
  cin >> n >> m >> q;
  vector<int> start(q);
  for(auto& i : start){
    cin >> i;
  }
  isjapan.resize(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/083ms10212 KiB
3Accepted1/14ms6876 KiB
4Accepted2/24ms7104 KiB
5Accepted1/14ms7460 KiB
6Accepted2/2268ms44844 KiB
7Accepted2/218ms8816 KiB
8Accepted2/210ms7896 KiB
9Accepted2/219ms8824 KiB
10Accepted2/243ms10232 KiB
11Runtime error0/283ms60512 KiB
12Runtime error0/3103ms61176 KiB
13Runtime error0/3115ms61620 KiB
14Runtime error0/3142ms63216 KiB
15Runtime error0/3192ms61820 KiB
16Runtime error0/3289ms62360 KiB
17Runtime error0/3141ms62156 KiB
18Runtime error0/3172ms63184 KiB
19Runtime error0/3172ms63192 KiB