uva11630 or hdu2987 Cyclic antimonotonic permutations(构造水题)
转载请注明出处: http://www.cnblogs.com/fraud/ ——by fraud
Cyclic antimonotonic permutations
Time Limit: 20000/5000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
1. Antimonotonic: for each consecutive 3 values pi-1, pi, pi+1 (1 < i < n), pi should either be the smallest or the biggest of the three values.
2. Cyclic: The permutation should consist of only one cycle, that is, when we use pi as a pointer from i to pi, it should be possible to start at position 1 and follow the pointers and reach all n positions before returning to position 1.
5
10
0
4 5 2 3 1
6 10 2 9 3 5 4 7 1 8
分奇数和偶数,随便搞一下
hdu由于没有special judge,无法AC
//#####################
//Author:fraud
//Blog: http://www.cnblogs.com/fraud/
//#####################
#include <iostream>
#include <sstream>
#include <ios>
#include <iomanip>
#include <functional>
#include <algorithm>
#include <vector>
#include <string>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <cctype>
using namespace std;
#define XINF INT_MAX
#define INF 0x3FFFFFFF
#define MP(X,Y) make_pair(X,Y)
#define PB(X) push_back(X)
#define REP(X,N) for(int X=0;X<N;X++)
#define REP2(X,L,R) for(int X=L;X<=R;X++)
#define DEP(X,R,L) for(int X=R;X>=L;X--)
#define CLR(A,X) memset(A,X,sizeof(A))
#define IT iterator
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<PII> VII;
typedef vector<int> VI;
#define MAXN 1000010
int a[MAXN];
int main()
{
int n;
while(scanf("%d",&n)&&n){
a[]=;
a[]=;
for(int i=;i<=n;i++){
if(i&)a[i]=i+;
else a[i]=i-;
}
if(n&)a[n]=n-;
else{
a[n]=n-;
a[n-]=n;
}
printf("%d",a[]);
for(int i=;i<=n;i++){
printf(" %d",a[i]);
}
printf("\n");
}
return ;
}
代码君
uva11630 or hdu2987 Cyclic antimonotonic permutations(构造水题)的更多相关文章
- 构造水题 Codeforces Round #206 (Div. 2) A. Vasya and Digital Root
题目传送门 /* 构造水题:对于0的多个位数的NO,对于位数太大的在后面补0,在9×k的范围内的平均的原则 */ #include <cstdio> #include <algori ...
- codeforces 22C System Administrator(构造水题)
转载请注明出处: http://www.cnblogs.com/fraud/ ——by fraud System Administrator Bob got a job as a s ...
- Educational Codeforces Round 94 (Rated for Div. 2) A. String Similarity (构造水题)
题意:给你一个长度为\(2*n-1\)的字符串\(s\),让你构造一个长度为\(n\)的字符串,使得构造的字符串中有相同位置的字符等于\(s[1..n],s[2..n+1],...,s[n,2n-1] ...
- hdu 2044:一只小蜜蜂...(水题,斐波那契数列)
一只小蜜蜂... Time Limit: / MS (Java/Others) Memory Limit: / K (Java/Others) Total Submission(s): Accepte ...
- hdu 2041:超级楼梯(水题,递归)
超级楼梯 Time Limit: / MS (Java/Others) Memory Limit: / K (Java/Others) Total Submission(s): Accepted Su ...
- codeforces Gym 100187L L. Ministry of Truth 水题
L. Ministry of Truth Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100187/p ...
- POJ 水题(刷题)进阶
转载请注明出处:優YoU http://blog.csdn.net/lyy289065406/article/details/6642573 部分解题报告添加新内容,除了原有的"大致题意&q ...
- Atcoder 水题选做
为什么是水题选做呢?因为我只会水题啊 ( 为什么是$Atcoder$呢?因为暑假学长来讲课的时候讲了三件事:不要用洛谷,不要用dev-c++,不要用单步调试.$bzoj$太难了,$Topcoder$整 ...
- CF330 C. Purification 认真想后就成水题了
C. Purification time limit per test 1 second memory limit per test 256 megabytes input standard inpu ...
随机推荐
- (转+原)python中的浅拷贝和深拷贝
转载请注明出处: http://www.cnblogs.com/darkknightzh/p/6069722.html 原网址: http://blog.csdn.net/sunshine_in_mo ...
- C++内存对象布局
本章主要介绍了c++类中成员变量.函数对象的在内存中布局. 当c++类中不包含virtual机制类的函数时,内部nostatic member被包含在每一个class object之中,就想c str ...
- JSONP有什么作用
1.解决跨域访问数据 由于同源策略的限制,XmlHttpRequest只允许请求当前源(域名.协议.端口)的资源,为了实现跨域请求,可以通过script标签实现跨域请求 ...
- canvas元素大小与绘图表面大小
原文链接:canvas总结:元素大小与绘图表面大小 前言 我们使用canvas的时候一般在canvas元素中直接设置它的width和height: 1 <canvas id="myCa ...
- HTML/CSS代码片段
内容简介:本文收集了我常用的CSS代码片段! *reset @charset "utf-8"; /* reset */ body, dl, dd, h1, h2, h3, h4, ...
- 一个人的旅行--hdu2066
一个人的旅行 Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Subm ...
- a标签href不跳转 禁止跳转
a标签href不跳转 禁止跳转 当页面中a标签不需要任何跳转时,从原理上来讲,可分如下两种方法: 标签属性href,使其指向空或不返回任何内容.如: <a href="javascri ...
- LeetCode_Spiral Matrix
Given a matrix of m x n elements (m rows, n columns), return all elements of the matrix in spiral or ...
- WebApi 能支持Session
由于项目实际需要,我希望让WebApi服务也能支持Session,所以便查找资料按照网上的方法开始着手实验. 然后就有了以下的代码,主要是说让WebApi支持Session,要重写Global.asa ...
- 【转】Linux中history历史命令使用方法详解
原文网址:http://os.51cto.com/art/201205/335040.htm 当你在玩Linux的时候,如果你经常使用命令行来控制你的Linux系统,那么有效地使用命令历史机制将会使效 ...