10589 | 2024-04-06 10:10:51 | UVince | Mágikus sorozat | cpp17 | Wrong answer 15/100 | 68ms | 23712 KiB |
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define all(a) a.begin(),a.end()
int main(){
ios_base::sync_with_stdio(0);cin.tie(0);
//freopen("be2.txt","r",stdin);
int n;
cin >> n;
vector<ll> z(n),a(n);
stack<pair<ll,ll>> last;
for (ll i = 0; i < n; i++)
{
cin>>z[i];
if (z[i]!=0) {
a[i]=1;
while (!last.empty() && last.top().first+last.top().second-1<=i) last.pop();
last.push({i,z[i]});
}
else {
a[i]=2;
auto [f,l]=last.top();
if (f+l-1>=i){
a[i]=a[i-f];
}
else {
auto [p,q]=last.top();
last.pop();
if (last.top().second==n){
if (a[i-p]==1) a[i]==2;
else a[i]=5-a[i-p];
}
}
}
}
for (ll i : a) cout<<i<<" ";
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Accepted | 3ms | 2100 KiB | ||||
2 | Accepted | 4ms | 2684 KiB | ||||
subtask2 | 15/15 | ||||||
3 | Accepted | 3ms | 2628 KiB | ||||
4 | Accepted | 3ms | 2768 KiB | ||||
5 | Accepted | 3ms | 2972 KiB | ||||
subtask3 | 0/15 | ||||||
6 | Accepted | 3ms | 3000 KiB | ||||
7 | Accepted | 3ms | 3100 KiB | ||||
8 | Accepted | 3ms | 3124 KiB | ||||
9 | Accepted | 3ms | 3116 KiB | ||||
10 | Wrong answer | 2ms | 3116 KiB | ||||
subtask4 | 0/30 | ||||||
11 | Wrong answer | 3ms | 3428 KiB | ||||
12 | Accepted | 3ms | 3464 KiB | ||||
13 | Wrong answer | 3ms | 3764 KiB | ||||
14 | Wrong answer | 3ms | 3960 KiB | ||||
subtask5 | 0/40 | ||||||
15 | Accepted | 52ms | 13144 KiB | ||||
16 | Wrong answer | 52ms | 13104 KiB | ||||
17 | Wrong answer | 52ms | 13096 KiB | ||||
18 | Wrong answer | 54ms | 13308 KiB | ||||
19 | Wrong answer | 57ms | 13420 KiB | ||||
20 | Wrong answer | 59ms | 13468 KiB | ||||
21 | Wrong answer | 59ms | 13764 KiB | ||||
22 | Wrong answer | 59ms | 13508 KiB | ||||
23 | Wrong answer | 59ms | 13540 KiB | ||||
24 | Wrong answer | 54ms | 13668 KiB | ||||
25 | Wrong answer | 54ms | 13668 KiB | ||||
26 | Wrong answer | 57ms | 13744 KiB | ||||
27 | Wrong answer | 46ms | 12540 KiB | ||||
28 | Wrong answer | 54ms | 14860 KiB | ||||
29 | Wrong answer | 54ms | 14240 KiB | ||||
30 | Accepted | 68ms | 23712 KiB | ||||
31 | Accepted | 61ms | 18588 KiB | ||||
32 | Accepted | 56ms | 15844 KiB |