77902024-01-11 10:15:38gortomiKülönböző katicákcpp17Forditási hiba
#include <bits/stdc++.h >
using namespace std;
vector<vector<int> > g;
vector<int> l, r, p, val, a;
void dfs(int v)
{
    for(auto x : g[v])
    {
        dfs(x);
        if(p[x] != -1) p[v] = 1 - p[x];
        l[v] = max(l[v], l[x] - 1);
        r[v] = min(r[v], r[x] + 1);
    }
    if(p[v] == -1 && a[v] != -1) p[v] = a[v] % 2;
    if(a[v] != -1 && p[v] != (a[v] % 2))
    {
        cout << "NEM\n";
        exit(0);
    }
}
void calc(int v)
{
    for(auto x : g[v])
    {
        if(val[v] - 1 < l[x]) val[x] = val[v] + 1;
        else val[x] = val[v] - 1;
        calc(x);
    }
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    g.resize(n + 1);
    l.resize(n + 1, 0);
    r.resize(n + 1, 1e7);
    a.resize(n + 1);
    p.resize(n + 1, -1);
    val.resize(n + 1);
    for(int i = 1; i <= n; i++)
    {
        int x;
        cin >> x;
        g[x].push_back(i);
    }
    for(int i = 1; i <= n; i++)
    {
        cin >> a[i];
        if(a[i] != -1) l[i] = r[i] = a[i];
    }
    dfs(1);
    for(int i = 1; i <= n; i++)
    {
        if(l[i] > r[i])
        {
            cout << "NEM\n";
            return 0;
        }
    }
    val[1] = l[1];
    calc(1);
    cout << "IGEN\n";
    for(int i = 1; i <= n; i++) cout << val[i] << " ";
}
Forditási hiba
exit status 1
main.cpp:1:10: fatal error: bits/stdc++.h : No such file or directory
    1 | #include <bits/stdc++.h >
      |          ^~~~~~~~~~~~~~~~
compilation terminated.
Exited with error status 1