5246 | 2023-04-23 21:07:23 | nmarci | Mágikus sorozat | cpp11 | Wrong answer 15/100 | 137ms | 16012 KiB |
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
const ll mod = 1e9 + 7;
int z[300100], a[300100];
int main(){
int n;
cin >> n;
for(int i = 1; i <= n; ++i){
cin >> z[i];
}
a[1] = 1;
int index = 0, maxind = 0;
for(int i = 2; i <= n; ++i){
if(z[i] > 0){
maxind = z[i] + 1;
index = 1;
}
if(index > 0){
a[i] = a[index];
++index;
if(index == maxind){
index = 0;
}
}
else{
if(a[maxind] == 2){
a[i] = 3;
}
else{
a[i] = 2;
}
maxind = 0;
}
}
for(int i = 1; i <= n; ++i){
cout << a[i] << " ";
}
return 0;
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Accepted | 3ms | 2164 KiB | ||||
2 | Accepted | 6ms | 2392 KiB | ||||
subtask2 | 15/15 | ||||||
3 | Accepted | 4ms | 2556 KiB | ||||
4 | Accepted | 4ms | 2928 KiB | ||||
5 | Accepted | 4ms | 2888 KiB | ||||
subtask3 | 0/15 | ||||||
6 | Accepted | 3ms | 3020 KiB | ||||
7 | Accepted | 3ms | 3148 KiB | ||||
8 | Accepted | 3ms | 3408 KiB | ||||
9 | Accepted | 3ms | 3416 KiB | ||||
10 | Wrong answer | 3ms | 3612 KiB | ||||
subtask4 | 0/30 | ||||||
11 | Wrong answer | 4ms | 3724 KiB | ||||
12 | Accepted | 3ms | 3736 KiB | ||||
13 | Wrong answer | 3ms | 3740 KiB | ||||
14 | Wrong answer | 3ms | 3996 KiB | ||||
subtask5 | 0/40 | ||||||
15 | Accepted | 90ms | 9348 KiB | ||||
16 | Wrong answer | 90ms | 10040 KiB | ||||
17 | Wrong answer | 93ms | 10932 KiB | ||||
18 | Wrong answer | 97ms | 11804 KiB | ||||
19 | Wrong answer | 107ms | 13036 KiB | ||||
20 | Wrong answer | 112ms | 14280 KiB | ||||
21 | Wrong answer | 118ms | 15408 KiB | ||||
22 | Wrong answer | 114ms | 15736 KiB | ||||
23 | Wrong answer | 115ms | 15684 KiB | ||||
24 | Wrong answer | 93ms | 15684 KiB | ||||
25 | Wrong answer | 97ms | 15688 KiB | ||||
26 | Wrong answer | 104ms | 16012 KiB | ||||
27 | Wrong answer | 82ms | 15424 KiB | ||||
28 | Accepted | 96ms | 15968 KiB | ||||
29 | Accepted | 93ms | 15968 KiB | ||||
30 | Accepted | 137ms | 15968 KiB | ||||
31 | Accepted | 116ms | 15960 KiB | ||||
32 | Accepted | 100ms | 15896 KiB |