155252025-02-20 10:45:06999Testnevelés óracpp17Compilation error
// Source: https://usaco.guide/general/io

#include <bits/stdc++.h>
using namespace std;

vector<int> vis;

bool dfs(vector<vector<int>>& v, int node){
    vis[node]=1;
    bool jo=true;
    for(int i : v[node]){
        if(vis[i]==1)return false;
        else if(vis[i]==0){
            jo&=dfs(v,i);
        }
    }
    vis[node]=2;
    return jo;
}

int main() {cout<<0;return 0;
    int n,k;cin>>n>>k;
    int mon=n;
    vector<vector<int>> v(n);
    vis.resize(n);
    vector<int> befok(n);
    for(int i = 0;i<k;i++){
        int a,b;cin>>a>>b;
        v[--a].push_back(--b);
        befok[b]++;
        if(befok[b]==1)mon--;
    }
    bool jo=true;
    for(int i = 0;i<n;i++){
        if(vis[i]==0){
            if(!dfs(v,i)){
                jo=false;
                break;
            }
        }
    }
    if(jo==false){
        cout<<0<<endl;
        return 0;
    }
    if(mon==1)cout<<1<<endl;
    else cout<<2<<endl;
    return 0;
    vector<int> volt(n);
    for(int i = 0;i<n;i++){
        if(befok[i]==0&&mon!=0&&!volt[i])bf.push_back(i);
        if(befok[i]==0&&mon<1){
            mon++;
            queue<int> q;
            q.push(i);
            while(!q.empty()){
                int node=q.front();
                q.pop();
                volt[node]=1;
                if(mon==1){
                    top1.push_back(node);
                }
                for(int u : v[node]){
                    befok[u]--;
                    if(befok[u]==0){
                        q.push(u);
                    }
                }
            }
        }
    }
}
Compilation error
open /var/local/lib/isolate/423/box/a.out: no such file or directory
main.cpp: In function 'int main()':
main.cpp:51:42: error: 'bf' was not declared in this scope
   51 |         if(befok[i]==0&&mon!=0&&!volt[i])bf.push_back(i);
      |                                          ^~
main.cpp:61:21: error: 'top1' was not declared in this scope
   61 |                     top1.push_back(node);
      |                     ^~~~