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 ...
随机推荐
- loghelper.cs 代码
唉,网上到处找一圈,真是麻烦,自己结合别人写的,重新整理一个. 这个破玩意最大的作用就是写微信那种没法顺利断点调试的程序的时候,在需要的地方写日志,然后去查看.真是回到当年用DW4写php的年代了,可 ...
- Node + Express + Mysql的CMS小结
因为之前用过上述的组合完成过很多系统,而这一次是为了实现一个帮助系统的静态网页发布.因为很久不写,重点说遇到的几个坑: 1.库版本的问题 比如mysql连接数据库一直报错,因为系统重装过,所以重新安装 ...
- emoji表情引发的JNI崩溃
今天突然接到客服那边的反馈说,有玩家反馈进游戏后不久就崩溃了,我先是怀疑网络问题,因为一连接聊天成功后就挂了.之后用logcat抓日志,发现挂在jni那里了 JNI DETECTED ERROR IN ...
- Meanshift filter实现简单图片的卡通化效果
利用Meanshift filter和canny边缘检测的效果,可以实现简单的图片的卡通化效果.简单的说,就是用Meanshift filter的结果减去canny算法的结果得到卡通化的效果. ...
- Linux: Set OR Change The Library Path
Linux: Set OR Change The Library Path by NIX CRAFT on APRIL 9, 2010 · 3 COMMENTS· LAST UPDATED AUGUS ...
- 解放双手——Android自动化测试
解放程序猿宝贵的右手(或者是左手) http://blog.csdn.net/eclipsexys/article/details/45622813 --Android自动化测试技巧 Google大神 ...
- netfilter分析
转自:http://blog.sina.com.cn/s/blog_a31ff26901013n07.html 一.概述 1. Netfilter/IPTables框架简介 Netfilter/IPT ...
- JAVA中取子字符串的几种方式
有这样一串字符串:String s = "共 100 页, 1 2 3 4..."; 假如我想把"100"给取出来,该如何做? 方法一: 采用split的方式 ...
- .NET分布式事务--TransactionScop
一.开启DTC服务 方式一 计算机—管理—服务—Distributed Transaction Coordinator—属性—开启 方式二 CMD命令子界面输入:net start msdtc 二.设 ...
- fastreport totalpage 只有设置doublepassreport为true 才正确否则为0
fastreport totalpage 只有设置doublepassreport为true 才正确否则为0