题目链接:http://www.bnuoj.com/bnuoj/problem_show.php?pid=29357

  直接模拟就可以了。。

 //STATUS:C++_AC_190MS_1884KB
#include <functional>
#include <algorithm>
#include <iostream>
//#include <ext/rope>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <numeric>
#include <cstring>
#include <cassert>
#include <cstdio>
#include <string>
#include <vector>
#include <bitset>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <list>
#include <set>
//#include <map>
using namespace std;
//#pragma comment(linker,"/STACK:102400000,102400000")
//using namespace __gnu_cxx;
//define
#define pii pair<int,int>
#define mem(a,b) memset(a,b,sizeof(a))
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define PI acos(-1.0)
//typedef
typedef long long LL;
typedef unsigned long long ULL;
//const
const int N=;
const int INF=0x3f3f3f3f;
const int MOD=,STA=;
//const LL LNF=1LL<<60;
const double EPS=1e-;
const double OO=1e15;
const int dx[]={-,,,};
const int dy[]={,,,-};
const int day[]={,,,,,,,,,,,,};
//Daily Use ...
inline int sign(double x){return (x>EPS)-(x<-EPS);}
template<class T> T gcd(T a,T b){return b?gcd(b,a%b):a;}
template<class T> T lcm(T a,T b){return a/gcd(a,b)*b;}
template<class T> inline T lcm(T a,T b,T d){return a/d*b;}
template<class T> inline T Min(T a,T b){return a<b?a:b;}
template<class T> inline T Max(T a,T b){return a>b?a:b;}
template<class T> inline T Min(T a,T b,T c){return min(min(a, b),c);}
template<class T> inline T Max(T a,T b,T c){return max(max(a, b),c);}
template<class T> inline T Min(T a,T b,T c,T d){return min(min(a, b),min(c,d));}
template<class T> inline T Max(T a,T b,T c,T d){return max(max(a, b),max(c,d));}
//End int stb[N<<],ans[N];
int T,n,x,y; int main(){
// freopen("in.txt","r",stdin);
int i,j,k,ca=,la,ra,lb,rb,reva,revb;
scanf("%d",&T);
while(T--)
{
scanf("%d%d%d",&n,&x,&y);
k=reva=revb=;
la=,ra=n;
lb=rb=N-;
while(k<n){
if(reva){
for(i=x;i-- && la<=ra;la++){
if(revb)stb[--lb]=la;
else stb[rb++]=la;
}
}
else {
for(i=x;i-- && la<=ra;ra--){
if(revb)stb[--lb]=ra;
else stb[rb++]=ra;
}
}
reva^=;
if(revb){
for(i=y;i-- && lb<rb;lb++)
ans[k++]=stb[lb];
}
else {
for(i=y;i-- && lb<rb;)
ans[k++]=stb[--rb];
}
revb^=;
} printf("Case %d:",ca++);
for(i=n-;i>=;i--){
printf(" %d",ans[i]);
}
putchar('\n');
}
return ;
}

BNUOJ-29357 Bread Sorting 模拟的更多相关文章

  1. BNUOJ 26474 Bread Sorting

    /*给出n个原始顺序的数,再给出要排成目标状态顺序,每次从第一个数列中选择三个,把这三个数中最右边的数放在最左边,然后其他两个数右 移一个单位,为你从原始状态能不能排序成目标状态. 本人YY的结论,从 ...

  2. bnuoj 4207 台风(模拟题)

    http://www.bnuoj.com/bnuoj/problem_show.php?pid=4207 [题意]:中文题,略 [题解]:模拟 [code]: #include <iostrea ...

  3. URAL(timus) 1280 Topological Sorting(模拟)

    Topological Sorting Time limit: 1.0 secondMemory limit: 64 MB Michael wants to win the world champio ...

  4. BNUOJ-26579 Bread Sorting YY

    题目链接:http://www.bnuoj.com/bnuoj/problem_show.php?pid=26579 考虑两个性质:蚂蚁的相对位置不变,蚂蚁碰撞时相当于对穿而过,然后排两次序就可以了. ...

  5. BNUOJ-29364 Bread Sorting 水题

    题目链接:http://www.bnuoj.com/bnuoj/problem_show.php?pid=29364 题意:给一个序列,输出序列中,二进制1的个数最少的数.. 随便搞搞就行了,关于更多 ...

  6. BNUOJ-26474 Bread Sorting 逆序对

    题目链接:http://www.bnuoj.com/bnuoj/problem_show.php?pid=26474 题意:给一个数列,可以对三个数操作:把最后一个数放到第一个,前两个数后移一位.问最 ...

  7. HDU 5122 K.Bro Sorting(模拟——思维题详解)

    题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5122 Problem Description Matt's friend K.Bro is an A ...

  8. HDU 6215 Brute Force Sorting 模拟双端链表

    一层一层删 链表模拟 最开始写的是一个一个删的 WA #include <bits/stdc++.h> #define PI acos(-1.0) #define mem(a,b) mem ...

  9. NCPC 2012 Bread Sorting

    逆序对数的应用: 逆序对数的写法有,二分,树状数组,分治: 学习一下: 树状数组版: 代码: #include<cstdio> #include<cstring> #inclu ...

随机推荐

  1. 认识FiddlerScript

    FiddlerScript 是Fiddler 的一项非常强大的功能,它允许你增强Fiddler UI,添加新的特性,修改请求与响应内容等等... 1.编写FiddlerScript FiddlerSc ...

  2. MySql 使用正则表达式

    MySql 用where 子句对正则表达式提供了支持,允许你指定正则表达式,注意mysql仅支持多数正则表达式实现的一个很小的子集. 1.基本字符匹配: SELECT prod_name FROM p ...

  3. EOJ-1708//POJ3334

    题意: 有一个连通器,由两个漏斗组成(关于漏斗的描述见描述). 现向漏斗中注入一定量的水,问最终水的绝对位置(即y轴坐标) 思路: 总体来说分为3种情况. 1.两个漏斗可能同时装有水. 2.只可能a漏 ...

  4. Linux---More命令 初级实现

    Linux: more已实现:more filename , quit不需要回车未实现:command | more 重定向 ,显示百分比 Waiting... /* Linux: more 已实现: ...

  5. 到底该不该熟悉掌握struts2的ONGL呢?

    其实,在学习网站开发过程中,其实不掌握ONGL也是可以的.我们完全可以使用JSTL和EL来代替OGNL. 只要存在要往页面传输内容,我们直接把对象放在request范围即可,这样我们就可以在jsp中使 ...

  6. Linux如何在虚拟机中挂载iso yum源

    首先,将作为源的iso的挂载到系统上. 代码如下: mount -o loop /dev/cdrom /mnt/iso/ 或者 mount -o loop /xxx/xxx.iso /mnt/iso/ ...

  7. ArcGIS Engine 连接SQL Server并建立关联

    IWorkspaceFactory  pWFactory=new OLEDBWorkspaceFactory(); IPropertySet  pPropertySet=new  PropertySe ...

  8. 转:Build Your First JavaScript Library

    http://net.tutsplus.com/tutorials/javascript-ajax/build-your-first-javascript-library/ Step 1: Creat ...

  9. IOS,Object C学习过程中遇到的attributes

    @property 定义一个属性 @synthesize 告诉编译器自动为属性自动生成 getter 和setter方法 在定义属性的时候会用到如下@attributes nonatomic,告诉编译 ...

  10. 大四实习准备2_java异常处理_android控件练习

    2015-4-24 Java 异常处理 可以有多个catch;ArrayIndexOutOfBoundsException类是Exception类的子类RuntimeException类的一个间接子类 ...