1. /*
       题意:给一个序列,表示每一项任务的难度,要求完成每一项任务的循序是按照难度由小到大的!输出三种符合要求的工作顺序的序列!
       思路:直接看代码....
    */
    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=; i<=n; ++i){
  30. scanf("%d", &nd[i].h);
  31. nd[i].p=i;
  32. }
  33. sort(nd+, nd+n+, cmp);
  34. int cnt = ;
  35. for(int i=; i<n; ++i){
  36. for(int j=i+; j<=n; ++j)
  37. if(nd[i].h == nd[j].h)
  38. ++cnt;//找到有多少对数相同的
  39. else{ i=j-; break; }
  40. }
  41.  
  42. if(cnt<) cout<<"NO"<<endl;//如果少于两对,一定不能
  43. else{
  44. cout<<"YES"<<endl;
  45. cout<<nd[].p;
  46. for(int i=; i<=n; ++i)//输出源序列
  47. cout<<" "<<nd[i].p;
  48. cout<<endl;
  49. int p;
  50. for(int i=; i<n; ++i)
  51. if( nd[i].h == nd[i+].h){//找到第一对相同的交换位置
  52. p = i;
  53. swap(&nd[i].p, &nd[i+].p);
  54. break;
  55. }
  56. cout<<nd[].p;
  57. for(int i=; i<=n; ++i)
  58. cout<<" "<<nd[i].p;
  59. cout<<endl;
  60. for(int i=; i<n; ++i)//找到第二对相同的交换位置
  61. if( nd[i].h == nd[i+].h && i != p){
  62. swap(&nd[i].p, &nd[i+].p);
  63. break;
  64. }
  65.  
  66. cout<<nd[].p;
  67. for(int i=; i<=n; ++i)
  68. cout<<" "<<nd[i].p;
  69. cout<<endl;
  70. }
  71.  
  72. return ;
  73. }

codeforces MUH and Important Things的更多相关文章

  1. cf471B MUH and Important Things

    B. MUH and Important Things time limit per test 1 second memory limit per test 256 megabytes input s ...

  2. codeforces 471B. MUH and Important Things 解题报告

    题目链接:http://codeforces.com/problemset/problem/471/B 题目意思:有 n 个 tasks,编号依次为 1 - n,每个 task 都有一定的难度值来评估 ...

  3. Codeforces Round #269 (Div. 2) B. MUH and Important Things

    It's time polar bears Menshykov and Uslada from the zoo of St. Petersburg and elephant Horace from t ...

  4. Codeforces Gym 100338C Important Roads 最短路+Tarjan找桥

    原题链接:http://codeforces.com/gym/100338/attachments/download/2136/20062007-winter-petrozavodsk-camp-an ...

  5. codeforces Gym 100338C Important Roads (重建最短路图)

    正反两次最短路用于判断边是不是最短路上的边,把最短路径上的边取出来建图.然后求割边.注意重边,和卡spfa. 正权,好好的dijkstra不用,用什么spfa? #include<bits/st ...

  6. codeforces MUH and Cube Walls

    题意:给定两个序列a ,b, 如果在a中存在一段连续的序列使得 a[i]-b[0]==k, a[i+1]-b[1]==k.... a[i+n-1]-b[n-1]==k 就说b串在a串中出现过!最后输出 ...

  7. codeforces471B

    MUH and Important Things CodeForces - 471B It's time polar bears Menshykov and Uslada from the zoo o ...

  8. CodeForces 471C MUH and House of Cards

    MUH and House of Cards Time Limit:1000MS     Memory Limit:262144KB     64bit IO Format:%I64d & % ...

  9. Codeforces Gym 100338C C - Important Roads tarjan

    C - Important RoadsTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/contes ...

随机推荐

  1. Leetcode 102 Binary Tree Level Order Traversal 二叉树+BFS

    二叉树的层次遍历 /** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * ...

  2. Android Error Message

    JAVA_HOME error. Add environment variable ANDROID_STUDIO, which is the same as %JAVA_HOME%, but one ...

  3. 使用Reveal查看任意App的技巧

    转:http://www.jianshu.com/p/4dc8f94ca27c 前言 Reveal(http://revealapp.com)是一个很强大的iOS View Hierarchy工具,与 ...

  4. asp.net中调用命令行

    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx. ...

  5. 利用EEPROM实现arduino的断电存储

    转载请注明:@小五义http://www.cnblogs.com/xiaowuyiQQ群:64770604 一.EEPROM简介 EEPROM (Electrically Erasable Progr ...

  6. windows下使用TortoiseGit代替Git命令行操作

    windows下使用TortoiseGit代替Git命令行操作 大家在使用svn的时候,都非常喜欢使用小乌龟,也就是TortoiseSVN:那么git也有小乌龟版本,即TortoiseGit. 1.安 ...

  7. Android SDK镜像的介绍使用

    由于一些原因,Google相关很多服务都无法访问,所以在很多时候我们SDK也无法升级,当然通过技术手段肯定可以解决,但是比较麻烦,而且下载速度也不怎么样. 这里笔者介绍一个国内的Android镜像站, ...

  8. 调用axis2开发的接口遇到的问题

    第1个异常 [org.apache.struts.actions.DispatchAction] – Dispatch[/myservice/NgCallServiceInfo]  to method ...

  9. 高吞吐量的分布式发布订阅消息系统Kafka--spring-integration-kafka的应用

    一.概述 Spring Integration Kafka 是基于 Apache Kafka 和Spring Integration来集成Kafka,对开发配置提供了方便. 二.配置 1.spring ...

  10. Hadoop2.x源码-编译剖析

    1.概述 最近,有小伙伴涉及到源码编译.然而,在编译期间也是遇到各种坑,在求助于搜索引擎,技术博客,也是难以解决自身所遇到的问题.笔者在被询问多次的情况下,今天打算为大家来写一篇文章来剖析下编译的细节 ...