#include<bits/stdc++.h>
using namespace std;
int a[200007];
int b[200007][7];
int ans[200007];
int main(){
for(int i=1;i<=5;i++)
b[1][i]=1;//第一个可以从1选到5
int n;
scanf("%d",&n);
for(int i=1;i<=n;i++)
scanf("%d",&a[i]);
for(int i=2;i<=n;i++){
for(int j=1;j<=5;j++){//遍历a[i]
for(int k=1;k<=5;k++){//遍历a[i-1]
if(j<k&&a[i]<a[i-1]&&b[i-1][k])//前一位可以选k,这一位才可以选j
b[i][j]=k;
else if(j>k&&a[i]>a[i-1]&&b[i-1][k])
b[i][j]=k;
else if(a[i-1]==a[i]&&j!=k&&b[i-1][k])
b[i][j]=k;
}
}
}
int flag=0;
int x=0;
for(int i=1;i<=5;i++){
if(b[n][i]==0)
continue;
x=i;//i是a[n]的答案
flag=1;
for(int j=n;j>=1;j--){
ans[j]=x;
x=b[j][x];//b[j][x]装的上一位的答案,x是这一位的答案
}
}
if(!flag)
printf("-1");
else{
for(int i=1;i<=n;i++)
printf("%d ",ans[i]);
}
return 0;
}
相关文章
- Educational Codeforces Round 69 (Rated for Div. 2)D(DP,思维)
- Educational Codeforces Round 57D(DP,思维)
- Codeforces Round #594 (Div. 1) D2. The World Is Just a Programming Task (Hard Version) 括号序列 思维
- Codeforces Round #575 (Div. 3) D1+D2. RGB Substring (easy version) D2. RGB Substring (hard version) (思维,枚举,前缀和)
- Codeforces Round #386 (Div. 2)(A-E)(水题 + deque模拟 + 思维 + 构造&贪心 + set模拟)
- Codeforces Round #416 (Div. 2)(A,思维题,暴力,B,思维题,暴力)
- Codeforces Round #243 (Div. 2) B(思维模拟题)
- Codeforces Round #380 (Div. 2)/729D Sea Battle 思维题
- Codeforces Round #218 (Div. 2) D. Vessels(思维 并查集)
- Codeforces Round #529 (Div. 3) E. Almost Regular Bracket Sequence (思维)