MUH and Important Things

CodeForces - 471B

It's time polar bears Menshykov and Uslada from the zoo of St. Petersburg and elephant Horace from the zoo of Kiev got down to business. In total, there are ntasks for the day and each animal should do each of these tasks. For each task, they have evaluated its difficulty. Also animals decided to do the tasks in order of their difficulty. Unfortunately, some tasks can have the same difficulty, so the order in which one can perform the tasks may vary.

Menshykov, Uslada and Horace ask you to deal with this nuisance and come up with individual plans for each of them. The plan is a sequence describing the order in which an animal should do all the n tasks. Besides, each of them wants to have its own unique plan. Therefore three plans must form three different sequences. You are to find the required plans, or otherwise deliver the sad news to them by stating that it is impossible to come up with three distinct plans for the given tasks.

Input

The first line contains integer n (1 ≤ n ≤ 2000) — the number of tasks. The second line contains n integers h1, h2, ..., hn (1 ≤ hi ≤ 2000), where hi is the difficulty of the i-th task. The larger number hi is, the more difficult the i-th task is.

Output

In the first line print "YES" (without the quotes), if it is possible to come up with three distinct plans of doing the tasks. Otherwise print in the first line "NO" (without the quotes). If three desired plans do exist, print in the second line ndistinct integers that represent the numbers of the tasks in the order they are done according to the first plan. In the third and fourth line print two remaining plans in the same form.

If there are multiple possible answers, you can print any of them.

Examples

Input
4
1 3 3 1
Output
YES
1 4 2 3
4 1 2 3
4 1 3 2
Input
5
2 4 1 4 8
Output
NO

Note

In the first sample the difficulty of the tasks sets one limit: tasks 1 and 4 must be done before tasks 2 and 3. That gives the total of four possible sequences of doing tasks : [1, 4, 2, 3], [4, 1, 2, 3], [1, 4, 3, 2], [4, 1, 3, 2]. You can print any three of them in the answer.

In the second sample there are only two sequences of tasks that meet the conditions — [3, 1, 2, 4, 5] and [3, 1, 4, 2, 5]. Consequently, it is impossible to make three distinct sequences of tasks.

sol:XJB构造三串不同的字典序最小的序列,十分容易,两个相同的就两两交换,多个相同的就用第一个与第二个或第三个(最后一个)交换,这样就凑到三种情况了

Ps:可能构造多种会比较困难,感觉只会n!的方法(GG)

#include <bits/stdc++.h>
using namespace std;
typedef int ll;
inline ll read()
{
ll s=;
bool f=;
char ch=' ';
while(!isdigit(ch))
{
f|=(ch=='-'); ch=getchar();
}
while(isdigit(ch))
{
s=(s<<)+(s<<)+(ch^); ch=getchar();
}
return (f)?(-s):(s);
}
#define R(x) x=read()
inline void write(ll x)
{
if(x<)
{
putchar('-'); x=-x;
}
if(x<)
{
putchar(x+''); return;
}
write(x/);
putchar((x%)+'');
return;
}
#define W(x) write(x),putchar(' ')
#define Wl(x) write(x),putchar('\n')
const int N=;
int n,Hash[N];
struct data
{
int Shuz;
}a[N];
int Pailie[N];
int Used[N];
vector<int>Jih[N];
int main()
{
int i,j,Fas=;
R(n);
for(i=;i<=n;i++)
{
R(a[i].Shuz); Hash[++*Hash]=a[i].Shuz;
}
sort(Hash+,Hash+*Hash+);
*Hash=unique(Hash+,Hash+*Hash+)-Hash-;
for(i=;i<=n;i++)
{
a[i].Shuz=lower_bound(Hash+,Hash+*Hash+,a[i].Shuz)-Hash;
Jih[a[i].Shuz].push_back(i);
}
for(i=;i<=*Hash&&Fas<;i++)
{
if(Jih[i].size()==) Fas*=;
else if(Jih[i].size()>) Fas=;
}
if(Fas<) return *puts("NO");
puts("YES");
for(int Step=;Step<=;Step++)
{
bool Bo=;
for(i=;i<=*Hash;i++)
{
if(Bo)
{
Used[i]=;
for(j=;j<Jih[i].size();j++) W(Jih[i][j]);
continue;
}
if(Jih[i].size()==)
{
W(Jih[i][]); continue;
}
else if(Jih[i].size()==)
{
if(Used[i]==)
{
W(Jih[i][]); W(Jih[i][]); Bo=;
Used[i]++;
}
else if(Used[i]==)
{
W(Jih[i][]); W(Jih[i][]); Bo=;
Used[i]++;
}
else
{
W(Jih[i][]); W(Jih[i][]);
}
}
else
{
if(Used[i]==)
{
for(j=;j<Jih[i].size();j++) W(Jih[i][j]);
Bo=;
Used[i]++;
}
else if(Used[i]==)
{
W(Jih[i][]); W(Jih[i][]);
for(j=;j<Jih[i].size();j++) W(Jih[i][j]);
Bo=;
Used[i]++;
}
else
{
W(Jih[i][Jih[i].size()-]);
for(j=;j<Jih[i].size()-;j++) W(Jih[i][j]);
W(Jih[i][]);
Bo=;
}
}
}
puts("");
}
return ;
}
/*
input
4
1 3 3 1
output
YES
1 4 2 3
4 1 2 3
4 1 3 2
*/

codeforces471B的更多相关文章

随机推荐

  1. FreeRTOS创建任务

    创建任务的函数如下: 第一个参数是:任务函数指针,即任务函数名. 敲黑板:创建任务和任务函数是两码事,一定要分清楚: 第二个参数是:这个参数不被FREE RTOS调用,就是辅助调试用的: 第三个参数是 ...

  2. ubuntu14.04下播放器SMplayer的安装

    1. Mplayer 与 SMplayer的区别 虽然MPlayer播放器是人类史上最强大的播放器(参数超过千个),但是其默认编译没有界面,所以写参数时间甚至比看片时间还长.虽然编译时候可以选择--e ...

  3. Java8中的HashMap分析

    本篇文章是网上多篇文章的精华的总结,结合自己看源代码的一些感悟,其中线程安全性和性能测试部分并未做实践测试,直接是“拿来”网上的博客的. 哈希表概述 哈希表本质上一个数组,数组中每一个元素称为一个箱子 ...

  4. 安卓自动化测试案例(跑在MonkeyRunner上)

    首先文件所在目录: MonkeyRunner所在目录: 运行命令(通过cd 命令  进入Tools目录下): 运行脚本:monkeyrunner.bat ..\honeywell\jsq.py 源文件 ...

  5. [Oracle]如何取Control File 的Dump

    ]如何取Control File 的Dump: SQL> alter session set events 'immediate trace name controlf level 3';SQL ...

  6. KMeans算法分析以及实现

    KMeans KMeans是一种无监督学习聚类方法, 目的是发现数据中数据对象之间的关系,将数据进行分组,组内的相似性越大,组间的差别越大,则聚类效果越好. 无监督学习,也就是没有对应的标签,只有数据 ...

  7. Jlink使用技巧之虚拟串口功能

    前言 串口调试是单片机开发过程必不可少的一个功能,一般是使用一个UART-TTL的串口模块来实现串口的功能,其实下载调试使用的Jlink仿真器也可以实现串口调试的功能,本篇文章将介绍如何使用Jlink ...

  8. 理解标准盒模型和怪异模式&box-sizing属性

    盒子模型 主要有两种,w3c标准盒模型,IE下的怪异盒模型,其实还有就是弹性盒模型(上篇文章我们用他很好的解决了对齐问题) DTD规范 盒模型分为:标准w3c盒模型.IE盒模型.以及css中的伸缩盒模 ...

  9. Redis_简单使用

    可基于内存也可持久化的Key-Value(字典, Remote Dictionary Server,远程字典服务器)数据库. 客户端:http://redis.io/clients 命令:http:/ ...

  10. RSA公钥文件解密密文的原理分析

    前言 最近在学习RSA加解密过程中遇到一个这样的难题:假设已知publickey公钥文件和加密后的密文flag,如何对其密文进行解密,转换成明文~~ 分析 对于rsa算法的公钥与私钥的产生,我们可以了 ...