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

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

codeforces MUH and Important Things

發布時間:2025/3/8 编程问答 29 豆豆
生活随笔 收集整理的這篇文章主要介紹了 codeforces MUH and Important Things 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
/*
   題意:給一個序列,表示每一項任務的難度,要求完成每一項任務的循序是按照難度由小到大的!輸出三種符合要求的工作順序的序列!
   思路:直接看代碼....
*/
1
#include<iostream> 2 #include<cstring> 3 #include<cstdio> 4 #include<algorithm> 5 #define N 2005 6 using namespace std; 7 struct node{ 8 int h; 9 int p; 10 }; 11 12 node nd[N]; 13 14 int vis[N]; 15 16 bool cmp(node a, node b){ 17 return a.h < b.h; 18 } 19 20 void swap(int *p, int *q){ 21 int t = *p; 22 *p = *q; 23 *q = t; 24 } 25 26 int main(){ 27 int n; 28 scanf("%d", &n); 29 for(int i=1; i<=n; ++i){ 30 scanf("%d", &nd[i].h); 31 nd[i].p=i; 32 } 33 sort(nd+1, nd+n+1, cmp); 34 int cnt = 0; 35 for(int i=1; i<n; ++i){ 36 for(int j=i+1; j<=n; ++j) 37 if(nd[i].h == nd[j].h) 38 ++cnt;//找到有多少對數相同的 39 else{ i=j-1; break; } 40 } 41 42 43 if(cnt<2) cout<<"NO"<<endl;//如果少于兩對,一定不能 44 else{ 45 cout<<"YES"<<endl; 46 cout<<nd[1].p; 47 for(int i=2; i<=n; ++i)//輸出源序列 48 cout<<" "<<nd[i].p; 49 cout<<endl; 50 int p; 51 for(int i=1; i<n; ++i) 52 if( nd[i].h == nd[i+1].h){//找到第一對相同的交換位置 53 p = i; 54 swap(&nd[i].p, &nd[i+1].p); 55 break; 56 } 57 cout<<nd[1].p; 58 for(int i=2; i<=n; ++i) 59 cout<<" "<<nd[i].p; 60 cout<<endl; 61 for(int i=1; i<n; ++i)//找到第二對相同的交換位置 62 if( nd[i].h == nd[i+1].h && i != p){ 63 swap(&nd[i].p, &nd[i+1].p); 64 break; 65 } 66 67 cout<<nd[1].p; 68 for(int i=2; i<=n; ++i) 69 cout<<" "<<nd[i].p; 70 cout<<endl; 71 } 72 73 return 0; 74 }

?

轉載于:https://www.cnblogs.com/hujunzheng/p/3996118.html

總結

以上是生活随笔為你收集整理的codeforces MUH and Important Things的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。