Why does this give WA?


#1
bool findCycle(vector<unordered_set<int>>& graph, int source, vector<bool>& visited, vector<bool>& recStack){
    if(visited[source])
        return false;
    visited[source] = true;
    recStack[source] = true;
    for(auto i : graph[source]){
        if(recStack[i] || findCycle(graph,i,visited,recStack))
            return true;
    }
    return recStack[source] = false;
}
int Solution::solve(int A, vector<int> &B, vector<int> &C) {
    vector<unordered_set<int>> graph(A);
    int n = B.size();
    if(n==0 || n==1)
        return 1;
    for(int i=0;i<n;i++){
        graph[B[i]-1].insert(C[i]-1);
    }
    vector<bool> visited(n,false);
    vector<bool> recStack(n,false);
    for(int i=0;i<A;i++){
        if(!visited[i] && findCycle(graph,i,visited,recStack))
            return 0;
    }
    return 1;
}