14292022-09-20 13:06:27BenceSzínes facpp11Compilation error
#include <iostream>
#include <queue>
#include <vector>
using namespace std;

struct adat
{
    vector <int> sz;
    int tav, szin;

};
queue <int > s;

int n,i,a,maxi=INT_MAX,akt;

int main()
{
    cin>>n;

    vector <adat> x(n+1);
    x[1].tav=1;
    for(i=2; i<=n; ++i)
    {
        cin>>a;
        x[a].sz.push_back(i);
        x[i].tav=x[a].tav+1;

    }

    for(i=1; i<=n; ++i)
    {
        if(x[i].sz.size()==0) maxi=min(maxi,x[i].tav);
    }

    s.push(1);
    x[1].szin=1;
    while(!s.empty())
    {
        akt=s.front();
        s.pop();
        for(auto &e: x[akt].sz)
        {
            if(x[akt].szin==maxi)
            x[e].szin=1;
            else x[e].szin=x[akt].szin+1;
            s.push(e);
        }
    }
    cout<<maxi<<'\n';

    for(i=1; i<=n; ++i) cout<<x[i].szin<<' ';
    return 0;
}
Compilation error
exit status 1
main.cpp:14:16: error: 'INT_MAX' was not declared in this scope
   14 | int n,i,a,maxi=INT_MAX,akt;
      |                ^~~~~~~
main.cpp:3:1: note: 'INT_MAX' is defined in header '<climits>'; did you forget to '#include <climits>'?
    2 | #include <queue>
  +++ |+#include <climits>
    3 | #include <vector>
main.cpp: In function 'int main()':
main.cpp:39:9: error: 'akt' was not declared in this scope
   39 |         akt=s.front();
      |         ^~~
Exited with error status 1