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. Objective-C autoreleasepool深入理解

    Objective-C autorelease // main.m int main(int argc, char * argv[]) { @autoreleasepool { } } clang - ...

  2. Tensorflow[源码安装时bazel行为解析]

    0. 引言 通过源码方式安装,并进行一定程度的解读,有助于理解tensorflow源码,本文主要基于tensorflow v1.8源码,并借鉴于如何阅读TensorFlow源码. 首先,自然是需要去b ...

  3. 基于TDA4863-2的单级PFC反激LED电源设计与仿真

    LED是一个非线性器件,正向电压的微小变化会引起电流的巨大变化:LED是一个半导体二极管,其伏安特性随温度变化而变化(-2mV/℃),假如温度升高,在恒压驱动下LED的电流会增加.长期超过额定电流工作 ...

  4. Python进阶:函数式编程(高阶函数,map,reduce,filter,sorted,返回函数,匿名函数,偏函数)...啊啊啊

    函数式编程 函数是Python内建支持的一种封装,我们通过把大段代码拆成函数,通过一层一层的函数调用,就可以把复杂任务分解成简单的任务,这种分解可以称之为面向过程的程序设计.函数就是面向过程的程序设计 ...

  5. Scala学习(八)---Scala继承

    Scala继承 摘要: 在本篇中,你将了解到Scala的继承与Java和C++最显著的不同.要点包括: 1. extends.final关键字和Java中相同 2. 重写方法时必须用override ...

  6. [JSOI2016]轻重路径[树链剖分]

    题意 题目链接 分析 先对原树树剖,在一次删点操作后从根节点开始二分,如果一条边从重边变成轻边,必然有 \(size_u\le \frac{1}{2}size_{rt}\) (取等号是特判对应儿子消失 ...

  7. Jmeter(三十五)_精确实现网页爬虫

    Jmeter实现了一个网站文章的爬虫,可以把所有文章分类保存到本地文件中,并以文章标题命名 它原理就是对网页提交一个请求,然后把返回的所有值提取出来,利用ForEach控制器去实现遍历.下面来介绍一下 ...

  8. Stanford Word Segmenter的特定领域训练

    有没有人自己训练过Stanford Word Segmenter分词器,因为我想做特定领域的分词,但在使用Stanford Word Segmenter分词的时候发现对于我想做的领域的一些词分词效果并 ...

  9. 《Linux内核分析》第七周学习笔记

    <Linux内核分析>第七周学习笔记 可执行程序的装载 郭垚 原创作品转载请注明出处 <Linux内核分析>MOOC课程http://mooc.study.163.com/co ...

  10. Hibernate_HQL

    public class According_condition { public static void main(String[]args){ Session session=HibernateU ...