60882023-10-29 17:50:45horvathabelUtazás (40)cpp17Wrong answer 15/40150ms58616 KiB
#include <bits/stdc++.h>
using namespace std;
vector<int> g[1000001];
vector<pair<bool,int>> mego;
void bfs(int x){
    mego[x].second=0;
    queue<int> q;
    q.push(x);
    while (!q.empty()){
        int v=q.front();
        q.pop();
        for (int x: g[v]){
            if (mego[x].first!=1){
                mego[x]={!mego[v].first,mego[v].second+1};
                q.push(x);
            }
        }
    }
}
int main()
{
    int n,m,k;
    cin>>n>>m>>k;
    mego.resize(n+1, {0,1e9});
    vector<int> ans;
    for (int q=0; q<k;q++){
        int x;
        cin>>x;
        ans.push_back(x);
    }
    vector<int> x(n+1,0);
    for (int i=0; i<m;i++){
        int a,b;
        cin>>a>>b;
        x[a]++;
        g[b].push_back(a);
    }
    for (int i=1; i<=n;i++){
            if (x[i]==0){
                bfs(i);
            }
    }
   for (int x: ans) cout<<(mego[x].first==1? "A\n" :"B\n");


}
SubtaskSumTestVerdictTimeMemory
base15/40
1Accepted0/024ms48948 KiB
2Wrong answer0/097ms53888 KiB
3Accepted1/118ms50348 KiB
4Accepted2/223ms50624 KiB
5Accepted1/123ms50636 KiB
6Accepted2/219ms50528 KiB
7Accepted2/226ms50844 KiB
8Accepted2/226ms51200 KiB
9Wrong answer0/226ms51092 KiB
10Accepted2/229ms51468 KiB
11Wrong answer0/248ms52880 KiB
12Accepted3/348ms53320 KiB
13Wrong answer0/354ms53916 KiB
14Wrong answer0/354ms54532 KiB
15Wrong answer0/350ms55388 KiB
16Wrong answer0/350ms56124 KiB
17Wrong answer0/386ms57860 KiB
18Wrong answer0/3150ms58616 KiB
19Wrong answer0/3145ms58612 KiB