5145 | 2023-04-20 13:02:23 | anon | Mágikus sorozat | cpp17 | Wrong answer 15/100 | 138ms | 13864 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;
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Accepted | 3ms | 1688 KiB | ||||
2 | Accepted | 6ms | 2204 KiB | ||||
subtask2 | 15/15 | ||||||
3 | Accepted | 3ms | 2316 KiB | ||||
4 | Accepted | 3ms | 2272 KiB | ||||
5 | Accepted | 3ms | 2336 KiB | ||||
subtask3 | 0/15 | ||||||
6 | Accepted | 3ms | 2428 KiB | ||||
7 | Accepted | 3ms | 2776 KiB | ||||
8 | Accepted | 2ms | 2644 KiB | ||||
9 | Accepted | 2ms | 2636 KiB | ||||
10 | Wrong answer | 3ms | 2768 KiB | ||||
subtask4 | 0/30 | ||||||
11 | Wrong answer | 3ms | 2900 KiB | ||||
12 | Accepted | 3ms | 2900 KiB | ||||
13 | Wrong answer | 3ms | 3224 KiB | ||||
14 | Wrong answer | 3ms | 3168 KiB | ||||
subtask5 | 0/40 | ||||||
15 | Accepted | 90ms | 12480 KiB | ||||
16 | Wrong answer | 90ms | 12692 KiB | ||||
17 | Wrong answer | 93ms | 12700 KiB | ||||
18 | Wrong answer | 97ms | 12712 KiB | ||||
19 | Wrong answer | 107ms | 12588 KiB | ||||
20 | Wrong answer | 112ms | 12840 KiB | ||||
21 | Wrong answer | 115ms | 13104 KiB | ||||
22 | Wrong answer | 112ms | 13032 KiB | ||||
23 | Wrong answer | 115ms | 13312 KiB | ||||
24 | Wrong answer | 94ms | 13368 KiB | ||||
25 | Wrong answer | 97ms | 13240 KiB | ||||
26 | Wrong answer | 105ms | 13452 KiB | ||||
27 | Wrong answer | 82ms | 12404 KiB | ||||
28 | Accepted | 96ms | 13652 KiB | ||||
29 | Accepted | 93ms | 13572 KiB | ||||
30 | Accepted | 138ms | 13676 KiB | ||||
31 | Accepted | 119ms | 13788 KiB | ||||
32 | Accepted | 100ms | 13864 KiB |