1132021-01-13 08:23:55kidesoSzínes facpp11Wrong answer 5/50112ms10420 KiB
#include <iostream>
#include <vector>

using namespace std;

//ifstream cin("szin.in");
//ofstream cout("szin.out");

struct adat
{
    int apa, tav, fiu;
};

vector <adat> x;
int N, i, a, k;

int main()
{
    cin >> N;

    k = N + 1;
    x.resize(N + 1);
    x[1].apa = -1;
    x[1].tav = 1;
    for (i = 2; i <= N; ++i)
    {
        cin >> a;
        ++x[a].fiu;
        x[i].apa = a;
        x[i].tav = x[a].tav + 1;
    }

    for (i = 1; i <= N; ++i)
        if (x[i].fiu == 0 && x[i].tav < k) k = x[i].tav;

    cout << k << '\n';

    for (i = 1; i <= N; ++i)
        if (x[i].tav <= k) cout << x[i].tav << ' ';
        else cout << 1 << ' ';
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base5/50
1Accepted0/01ms1804 KiB
2Accepted0/04ms2072 KiB
3Wrong answer0/11ms1940 KiB
4Wrong answer0/41ms1940 KiB
5Accepted5/596ms7584 KiB
6Wrong answer0/2112ms7572 KiB
7Wrong answer0/3101ms7580 KiB
8Wrong answer0/297ms7576 KiB
9Wrong answer0/2100ms8272 KiB
10Wrong answer0/2104ms9528 KiB
11Wrong answer0/298ms10420 KiB
12Wrong answer0/296ms10412 KiB
13Wrong answer0/297ms10408 KiB
14Wrong answer0/2108ms10416 KiB
15Wrong answer0/2108ms10416 KiB
16Wrong answer0/2101ms10412 KiB
17Wrong answer0/2108ms10408 KiB
18Wrong answer0/2108ms10412 KiB
19Wrong answer0/2101ms10408 KiB
20Wrong answer0/297ms10420 KiB
21Wrong answer0/2101ms10416 KiB
22Wrong answer0/297ms10420 KiB
23Wrong answer0/2104ms10408 KiB
24Wrong answer0/3100ms10416 KiB