51452023-04-20 13:02:23anonMágikus sorozatcpp17Wrong answer 15/100138ms13864 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
        {
            if(j && a[i - j + 1] == 2)
                a[i] = 3;
            else
                a[i] = 2;

            j = 0;
            i++;
        }
    }

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

    cout << endl;

    return 0;
}

SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted3ms1688 KiB
2Accepted6ms2204 KiB
subtask215/15
3Accepted3ms2316 KiB
4Accepted3ms2272 KiB
5Accepted3ms2336 KiB
subtask30/15
6Accepted3ms2428 KiB
7Accepted3ms2776 KiB
8Accepted2ms2644 KiB
9Accepted2ms2636 KiB
10Wrong answer3ms2768 KiB
subtask40/30
11Wrong answer3ms2900 KiB
12Accepted3ms2900 KiB
13Wrong answer3ms3224 KiB
14Wrong answer3ms3168 KiB
subtask50/40
15Accepted90ms12480 KiB
16Wrong answer90ms12692 KiB
17Wrong answer93ms12700 KiB
18Wrong answer97ms12712 KiB
19Wrong answer107ms12588 KiB
20Wrong answer112ms12840 KiB
21Wrong answer115ms13104 KiB
22Wrong answer112ms13032 KiB
23Wrong answer115ms13312 KiB
24Wrong answer94ms13368 KiB
25Wrong answer97ms13240 KiB
26Wrong answer105ms13452 KiB
27Wrong answer82ms12404 KiB
28Accepted96ms13652 KiB
29Accepted93ms13572 KiB
30Accepted138ms13676 KiB
31Accepted119ms13788 KiB
32Accepted100ms13864 KiB