179712025-09-24 18:03:03algoproTestnevelés óracpp17Forditási hiba
// UUID: 8ce63a68-f7b9-4bb7-aeca-ef6f1a84c05b
#include <algorithm>
#include <bits/stdc++.h>
#include <climits>
#include <queue>
#include <vector>
using namespace std;

//A maximális int az 2^31-1 ami nagyobb mint 10^9 de kisseb mint 10^10

int main() {
int n, t;
    cin >> n >> t;

    vector<vector<int>> fa(n);
    vector<int> sz(n, 0);

    for (int i = 0; i < t; i++) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        fa[a].push_back(b);
        indeg[b]++;
    }

    queue<int> q;
    for (int i = 0; i < n; i++) {
        if (indeg[i] == 0) q.push(i);
    }

    vector<int> lista;
    int count = 0;

    while (!q.empty()) {
        if (q.size() > 1) count++; 

        int u = q.front();
        q.pop();
        lista.push_back(u);

        for (int v : fa[u]) {
            indeg[v]--;
            if (indeg[v] == 0) q.push(v);
        }
    }

    if ((int)lista.size() != n) {
        cout << 0;
        return 0;
    }

    cout << count << "\n";
    for (int x : lista) cout << x + 1 << " ";
    cout << "\n";
}
Forditási hiba
open /var/local/lib/isolate/402/box/a.out: no such file or directory
main.cpp: In function 'int main()':
main.cpp:23:9: error: 'indeg' was not declared in this scope; did you mean 'index'?
   23 |         indeg[b]++;
      |         ^~~~~
      |         index
main.cpp:28:13: error: 'indeg' was not declared in this scope; did you mean 'index'?
   28 |         if (indeg[i] == 0) q.push(i);
      |             ^~~~~
      |             index
main.cpp:42:13: error: 'indeg' was not declared in this scope; did you mean 'index'?
   42 |             indeg[v]--;
      |             ^~~~~
      |             index