3552021-10-28 12:37:25Kevinke12Utazás (40)cpp14Wrong answer 17/40185ms36088 KiB
#include <iostream>
#include <bits/stdc++.h>
using namespace std;

int N, M, Q, be1, be2;
vector<int> ellista[200005];
vector<int> ellistaF[200005];
int h[200005]; //0-undefined, 1-nyero, -1 veszto
bool voltmar[200005]; //0-undefined, 1-nyero, -1 veszto
vector<int> kerd;

int main()
{
    cin >> N >> M >> Q;
    for(int i = 0; i < Q; i++)
    {
        cin >> be1; kerd.push_back(be1);
    }
    for(int i = 0; i < M; i++)
    {
        cin >> be1 >> be2;
        ellista[be1].push_back(be1);
        ellistaF[be2].push_back(be1);
    }
    //Szelessegi
    vector<int> t;
    int mut=0;

    for(int i = 1; i <= N; i++)
    {
        if(ellista[i].size()==0)
        {
            t.push_back(i);
            h[i]=-1;
        }
    }
    while(mut<t.size())
    {
        if(h[t[mut]]==0) //még nincs értéke, nem jutok vesztobe
        {
            h[t[mut]]=-1;
        }
        for(int a:ellistaF[t[mut]])
        {
            if(voltmar[a]==false)
            {
                voltmar[a]=true;
                t.push_back(a);
            }
            if(h[t[mut]]==-1) //Tudom veszto helyzetbe juttatni -> ez nyero
                h[a]=1;
        }
        mut++;
    }

    /*for(int i = 1;i <= N; i++)
    {
        cout << i << ":" << h[i] << "\n";
    }*/
    for(int a:kerd)
    {
        if(h[a]==1)
            cout << "A\n";
        else
            cout << "B\n";
    }
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base17/40
1Accepted0/010ms20460 KiB
2Wrong answer0/0108ms27884 KiB
3Accepted1/19ms21704 KiB
4Accepted2/29ms21712 KiB
5Accepted1/19ms21720 KiB
6Accepted2/29ms21740 KiB
7Accepted2/213ms21964 KiB
8Accepted2/217ms22484 KiB
9Accepted2/214ms22100 KiB
10Accepted2/219ms22484 KiB
11Wrong answer0/245ms24148 KiB
12Accepted3/343ms24636 KiB
13Wrong answer0/365ms25216 KiB
14Wrong answer0/343ms25804 KiB
15Wrong answer0/345ms26332 KiB
16Wrong answer0/354ms26912 KiB
17Wrong answer0/385ms29384 KiB
18Wrong answer0/3164ms34172 KiB
19Wrong answer0/3185ms36088 KiB