codeforces MUH and Important Things
- /*
题意:给一个序列,表示每一项任务的难度,要求完成每一项任务的循序是按照难度由小到大的!输出三种符合要求的工作顺序的序列!
思路:直接看代码....
*/
1 #include<iostream>- #include<cstring>
- #include<cstdio>
- #include<algorithm>
- #define N 2005
- using namespace std;
- struct node{
- int h;
- int p;
- };
- node nd[N];
- int vis[N];
- bool cmp(node a, node b){
- return a.h < b.h;
- }
- void swap(int *p, int *q){
- int t = *p;
- *p = *q;
- *q = t;
- }
- int main(){
- int n;
- scanf("%d", &n);
- for(int i=; i<=n; ++i){
- scanf("%d", &nd[i].h);
- nd[i].p=i;
- }
- sort(nd+, nd+n+, cmp);
- int cnt = ;
- for(int i=; i<n; ++i){
- for(int j=i+; j<=n; ++j)
- if(nd[i].h == nd[j].h)
- ++cnt;//找到有多少对数相同的
- else{ i=j-; break; }
- }
- if(cnt<) cout<<"NO"<<endl;//如果少于两对,一定不能
- else{
- cout<<"YES"<<endl;
- cout<<nd[].p;
- for(int i=; i<=n; ++i)//输出源序列
- cout<<" "<<nd[i].p;
- cout<<endl;
- int p;
- for(int i=; i<n; ++i)
- if( nd[i].h == nd[i+].h){//找到第一对相同的交换位置
- p = i;
- swap(&nd[i].p, &nd[i+].p);
- break;
- }
- cout<<nd[].p;
- for(int i=; i<=n; ++i)
- cout<<" "<<nd[i].p;
- cout<<endl;
- for(int i=; i<n; ++i)//找到第二对相同的交换位置
- if( nd[i].h == nd[i+].h && i != p){
- swap(&nd[i].p, &nd[i+].p);
- break;
- }
- cout<<nd[].p;
- for(int i=; i<=n; ++i)
- cout<<" "<<nd[i].p;
- cout<<endl;
- }
- return ;
- }
codeforces MUH and Important Things的更多相关文章
- cf471B MUH and Important Things
B. MUH and Important Things time limit per test 1 second memory limit per test 256 megabytes input s ...
- codeforces 471B. MUH and Important Things 解题报告
题目链接:http://codeforces.com/problemset/problem/471/B 题目意思:有 n 个 tasks,编号依次为 1 - n,每个 task 都有一定的难度值来评估 ...
- 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 ...
- Codeforces Gym 100338C Important Roads 最短路+Tarjan找桥
原题链接:http://codeforces.com/gym/100338/attachments/download/2136/20062007-winter-petrozavodsk-camp-an ...
- codeforces Gym 100338C Important Roads (重建最短路图)
正反两次最短路用于判断边是不是最短路上的边,把最短路径上的边取出来建图.然后求割边.注意重边,和卡spfa. 正权,好好的dijkstra不用,用什么spfa? #include<bits/st ...
- 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串中出现过!最后输出 ...
- codeforces471B
MUH and Important Things CodeForces - 471B It's time polar bears Menshykov and Uslada from the zoo o ...
- CodeForces 471C MUH and House of Cards
MUH and House of Cards Time Limit:1000MS Memory Limit:262144KB 64bit IO Format:%I64d & % ...
- Codeforces Gym 100338C C - Important Roads tarjan
C - Important RoadsTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/contes ...
随机推荐
- Leetcode 102 Binary Tree Level Order Traversal 二叉树+BFS
二叉树的层次遍历 /** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * ...
- Android Error Message
JAVA_HOME error. Add environment variable ANDROID_STUDIO, which is the same as %JAVA_HOME%, but one ...
- 使用Reveal查看任意App的技巧
转:http://www.jianshu.com/p/4dc8f94ca27c 前言 Reveal(http://revealapp.com)是一个很强大的iOS View Hierarchy工具,与 ...
- asp.net中调用命令行
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx. ...
- 利用EEPROM实现arduino的断电存储
转载请注明:@小五义http://www.cnblogs.com/xiaowuyiQQ群:64770604 一.EEPROM简介 EEPROM (Electrically Erasable Progr ...
- windows下使用TortoiseGit代替Git命令行操作
windows下使用TortoiseGit代替Git命令行操作 大家在使用svn的时候,都非常喜欢使用小乌龟,也就是TortoiseSVN:那么git也有小乌龟版本,即TortoiseGit. 1.安 ...
- Android SDK镜像的介绍使用
由于一些原因,Google相关很多服务都无法访问,所以在很多时候我们SDK也无法升级,当然通过技术手段肯定可以解决,但是比较麻烦,而且下载速度也不怎么样. 这里笔者介绍一个国内的Android镜像站, ...
- 调用axis2开发的接口遇到的问题
第1个异常 [org.apache.struts.actions.DispatchAction] – Dispatch[/myservice/NgCallServiceInfo] to method ...
- 高吞吐量的分布式发布订阅消息系统Kafka--spring-integration-kafka的应用
一.概述 Spring Integration Kafka 是基于 Apache Kafka 和Spring Integration来集成Kafka,对开发配置提供了方便. 二.配置 1.spring ...
- Hadoop2.x源码-编译剖析
1.概述 最近,有小伙伴涉及到源码编译.然而,在编译期间也是遇到各种坑,在求助于搜索引擎,技术博客,也是难以解决自身所遇到的问题.笔者在被询问多次的情况下,今天打算为大家来写一篇文章来剖析下编译的细节 ...