| 16117 | 2025-04-03 08:14:43 | buzaszendvics | Legtávolabbi leszármazott | cpp17 | Forditási hiba |
#include <iostream>
using namespace std;
int os[100001], melyseg[100001];
int mely (int csucs)
{
if (!os[csucs]) return 0;
if (!melyseg[csucs]) melyseg[csucs] = mely(os[csucs])+1;
return melyseg[csucs];
}
int main()
{
int n;
cin >> n;
szomszli fa(n+1);
int apa, fia;
for (int i = 1; i < n; i++) {
cin >> apa >> fia;
os[fia] = apa;
}
mely(1);
int maxi = 1;
for (int i = 2; i <= n; i ++)
{
if (mely(i)>melyseg[maxi]) maxi = i;
}
cout << maxi;
return 0;
}
open /var/local/lib/isolate/439/box/a.out: no such file or directory
main.cpp: In function 'int main()':
main.cpp:20:5: error: 'szomszli' was not declared in this scope
20 | szomszli fa(n+1);
| ^~~~~~~~