日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 编程资源 > 编程问答 >内容正文

编程问答

【CodeForces - 471B】MUH and Important Things (模拟,细节)

發(fā)布時(shí)間:2023/12/10 编程问答 34 豆豆
生活随笔 收集整理的這篇文章主要介紹了 【CodeForces - 471B】MUH and Important Things (模拟,细节) 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

題干:

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.

題目大意:

? ?給定n個(gè)任務(wù),每個(gè)任務(wù)有一個(gè)難度值,現(xiàn)在要你輸出一個(gè)完成任務(wù)的三種序列,要求有二:1.如果難度值不同的話先完成難度值低的,難度值相同的任務(wù)先完成哪個(gè)都行。

解題報(bào)告:

? ?很簡(jiǎn)單的模擬題啊但是寫掛好多次,,難受難受、、、其實(shí)這題要想代碼短一點(diǎn),,上來(lái)就排序就完事了,然后掃一遍看前后兩個(gè)值相同的個(gè)數(shù)是否大于等于兩個(gè)? 如果小于兩個(gè)輸出NO 大于等于兩個(gè)就取前兩個(gè)然后亂搞。

AC代碼:(冗長(zhǎng)的代碼不想再讀第二遍)

#include<cstdio> #include<iostream> #include<algorithm> #include<queue> #include<map> #include<vector> #include<set> #include<string> #include<cmath> #include<cstring> #define ll long long #define pb push_back #define pm make_pair #define fi first #define se second using namespace std; const int MAX = 2e5 + 5; int bk[MAX]; int a[MAX]; int n; int c2,c3; struct Node {int dif,pos; } node[MAX]; bool cmp(Node a,Node b) {return a.dif<b.dif; } int main() {cin>>n;for(int i = 1; i<=n; i++) scanf("%d",a+i),bk[a[i]]++,node[i].dif=a[i],node[i].pos=i;for(int i = 1; i<=2000; i++) {if(bk[i] >= 3) c3++,c2++;if(bk[i] >= 2) c2++;}if(c3==0 && c2<=1) {puts("NO");return 0 ;}sort(node+1,node+n+1,cmp);puts("YES");if(c3 >= 1) {for(int i = 1; i<=2000; i++) {if(bk[i] >= 3) {c3=i;break;}}for(int i = 1,flag=0; i<=n;) {if(node[i].dif == c3 && flag == 0) {printf("%d %d %d ",node[i].pos,node[i+1].pos,node[i+2].pos);i+=3;flag=1;}else {printf("%d ",node[i].pos);i++;}}puts("");for(int i = 1,flag=0; i<=n;) {if(node[i].dif == c3 && flag == 0) {printf("%d %d %d ",node[i+1].pos,node[i].pos,node[i+2].pos);i+=3;flag=1;}else {printf("%d ",node[i].pos);i++;}}puts("");for(int i = 1,flag=0; i<=n;) {if(node[i].dif == c3 && flag == 0) {printf("%d %d %d ",node[i+2].pos,node[i+1].pos,node[i].pos);i+=3;flag=1;}else {printf("%d ",node[i].pos);i++;}} }else {int tot=0,c[4]={0};for(int i = 1; i<=2000; i++) {if(bk[i] == 2) c[++tot] = i;if(tot==2) break;}for(int i = 1; i<=n;) {if(node[i].dif == c[1]) {printf("%d %d ",node[i].pos,node[i+1].pos);i+=2;}else {printf("%d ",node[i].pos);i++;}}puts(""); for(int i = 1; i<=n;) {if(node[i].dif == c[2]) {printf("%d %d ",node[i+1].pos,node[i].pos);i+=2;}else {printf("%d ",node[i].pos);i++;}}puts("");for(int i = 1; i<=n;) {if(node[i].dif == c[1]) {printf("%d %d ",node[i+1].pos,node[i].pos);i+=2;}else {printf("%d ",node[i].pos);i++;}} }return 0 ;}

總結(jié):

? ?注意那個(gè)flag那個(gè)地方必須要有啊,不然比如n=10然后給你十個(gè)1,,,你就很難受了,,會(huì)發(fā)現(xiàn)多輸出了兩個(gè)數(shù)。

總結(jié)

以上是生活随笔為你收集整理的【CodeForces - 471B】MUH and Important Things (模拟,细节)的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。