10588 | 2024-04-06 10:09:14 | UVince | Mágikus sorozat | cpp17 | Wrong answer 15/100 | 68ms | 13320 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<int> z(n),a(n);
stack<pair<int,int>> last;
for (int 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 (int i : a) cout<<i<<" ";
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Accepted | 3ms | 2100 KiB | ||||
2 | Accepted | 4ms | 2436 KiB | ||||
subtask2 | 15/15 | ||||||
3 | Accepted | 3ms | 2308 KiB | ||||
4 | Accepted | 3ms | 2480 KiB | ||||
5 | Accepted | 3ms | 2800 KiB | ||||
subtask3 | 0/15 | ||||||
6 | Accepted | 3ms | 2724 KiB | ||||
7 | Accepted | 3ms | 2852 KiB | ||||
8 | Accepted | 3ms | 3064 KiB | ||||
9 | Accepted | 2ms | 3064 KiB | ||||
10 | Wrong answer | 3ms | 3068 KiB | ||||
subtask4 | 0/30 | ||||||
11 | Wrong answer | 3ms | 3100 KiB | ||||
12 | Accepted | 3ms | 3096 KiB | ||||
13 | Wrong answer | 3ms | 3096 KiB | ||||
14 | Wrong answer | 3ms | 3348 KiB | ||||
subtask5 | 0/40 | ||||||
15 | Accepted | 52ms | 7828 KiB | ||||
16 | Wrong answer | 52ms | 7820 KiB | ||||
17 | Wrong answer | 54ms | 7828 KiB | ||||
18 | Wrong answer | 54ms | 8036 KiB | ||||
19 | Wrong answer | 59ms | 8064 KiB | ||||
20 | Wrong answer | 59ms | 8088 KiB | ||||
21 | Wrong answer | 61ms | 8096 KiB | ||||
22 | Wrong answer | 59ms | 8064 KiB | ||||
23 | Wrong answer | 61ms | 8396 KiB | ||||
24 | Wrong answer | 54ms | 8256 KiB | ||||
25 | Wrong answer | 54ms | 8260 KiB | ||||
26 | Wrong answer | 57ms | 8260 KiB | ||||
27 | Wrong answer | 46ms | 7708 KiB | ||||
28 | Wrong answer | 54ms | 9104 KiB | ||||
29 | Wrong answer | 52ms | 8964 KiB | ||||
30 | Accepted | 68ms | 13320 KiB | ||||
31 | Accepted | 61ms | 11028 KiB | ||||
32 | Accepted | 57ms | 9676 KiB |