51442023-04-20 07:29:27anonMágikus sorozatcpp17Wrong answer 15/100143ms31616 KiB
#include <vector>
#include <iostream>

using ll = long long;
using namespace std;

int main()
{
    ll i, j, k, N;

    cin >> N;

    vector<ll> z(N + 1);

    for(i = 1; i <= N; i++)
        cin >> z[i];

    vector<ll> a(N + 1);
    a[1] = 1;

    i = 2;
    j = 0;

    while(i <= N)
    {
        if(z[i])
        {
            j = i;
            k = z[i];

            for(;i < j + k; i++)
                a[i] = a[i - j + 1];
        }
        else
        {
            a[i] = 2;

            if(j)
            {
                while(a[i] == a[i - j + 1]) a[i]++;
                j = 0;
            }

            i++;
        }
    }

    for(i = 1; i <= N; i++)
        cout << a[i] << ' ';

    cout << endl;

    return 0;
}

SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted3ms1808 KiB
2Accepted6ms2476 KiB
subtask215/15
3Accepted4ms2468 KiB
4Accepted3ms2440 KiB
5Accepted3ms2708 KiB
subtask30/15
6Accepted3ms2772 KiB
7Accepted3ms2988 KiB
8Accepted3ms3208 KiB
9Accepted2ms3288 KiB
10Wrong answer2ms3292 KiB
subtask40/30
11Wrong answer4ms3552 KiB
12Accepted4ms3828 KiB
13Wrong answer3ms4040 KiB
14Wrong answer3ms4000 KiB
subtask50/40
15Accepted90ms14100 KiB
16Wrong answer92ms14492 KiB
17Wrong answer96ms15212 KiB
18Wrong answer98ms16140 KiB
19Wrong answer108ms17284 KiB
20Wrong answer115ms18564 KiB
21Wrong answer119ms20184 KiB
22Wrong answer115ms21360 KiB
23Wrong answer119ms22888 KiB
24Wrong answer94ms23528 KiB
25Wrong answer98ms24420 KiB
26Wrong answer108ms25508 KiB
27Wrong answer82ms25092 KiB
28Accepted97ms26984 KiB
29Accepted93ms27680 KiB
30Accepted143ms29556 KiB
31Accepted119ms30836 KiB
32Accepted101ms31616 KiB