BNUOJ-29357 Bread Sorting 模拟
题目链接: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 模拟的更多相关文章
- BNUOJ 26474 Bread Sorting
/*给出n个原始顺序的数,再给出要排成目标状态顺序,每次从第一个数列中选择三个,把这三个数中最右边的数放在最左边,然后其他两个数右 移一个单位,为你从原始状态能不能排序成目标状态. 本人YY的结论,从 ...
- bnuoj 4207 台风(模拟题)
http://www.bnuoj.com/bnuoj/problem_show.php?pid=4207 [题意]:中文题,略 [题解]:模拟 [code]: #include <iostrea ...
- URAL(timus) 1280 Topological Sorting(模拟)
Topological Sorting Time limit: 1.0 secondMemory limit: 64 MB Michael wants to win the world champio ...
- BNUOJ-26579 Bread Sorting YY
题目链接:http://www.bnuoj.com/bnuoj/problem_show.php?pid=26579 考虑两个性质:蚂蚁的相对位置不变,蚂蚁碰撞时相当于对穿而过,然后排两次序就可以了. ...
- BNUOJ-29364 Bread Sorting 水题
题目链接:http://www.bnuoj.com/bnuoj/problem_show.php?pid=29364 题意:给一个序列,输出序列中,二进制1的个数最少的数.. 随便搞搞就行了,关于更多 ...
- BNUOJ-26474 Bread Sorting 逆序对
题目链接:http://www.bnuoj.com/bnuoj/problem_show.php?pid=26474 题意:给一个数列,可以对三个数操作:把最后一个数放到第一个,前两个数后移一位.问最 ...
- HDU 5122 K.Bro Sorting(模拟——思维题详解)
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5122 Problem Description Matt's friend K.Bro is an A ...
- HDU 6215 Brute Force Sorting 模拟双端链表
一层一层删 链表模拟 最开始写的是一个一个删的 WA #include <bits/stdc++.h> #define PI acos(-1.0) #define mem(a,b) mem ...
- NCPC 2012 Bread Sorting
逆序对数的应用: 逆序对数的写法有,二分,树状数组,分治: 学习一下: 树状数组版: 代码: #include<cstdio> #include<cstring> #inclu ...
随机推荐
- nagios plugins之 check_http
nagios下的check_http ZT具体参数是一个比较重要的点,我带大家来看看.. //显示版本 #./check_http -V check_http v2053 (nagios-plugin ...
- 关于DataTables一些小结
最近项目中使用了DataTables,故小结了一下. 导入CSS文件<link rel="stylesheet" href="<%=base %>/js ...
- pflua:用Lua编写的高性能网络包过滤工具箱
http://www.csdn.net/article/2014-09-05/2821568-pflua
- 钣金的折弯成型工艺(Press Braking)
钣金的折弯成型:金属板材的弯曲和成型是在弯板机上进行的,将要成型的板材放置在弯板机上,用升降杠杆将制动片提起,工件滑动到适当的位置,然后将制动片降低到要成型的板材上,通过对弯板机上的弯曲杠杆施力而实现 ...
- (转)CSS+DIV float 定位
来自:http://www.cnblogs.com/iyangyuan/archive/2013/03/27/2983813.html 很早以前就接触过CSS,但对于浮动始终非常迷惑,可能是自身理解能 ...
- linux命令之-pstree使用说明
pstree shows running processes as a tree. The tree is rooted at either pid or init if pid is omitte ...
- 【HDOJ】4605 Magic Ball Game
思路1:树状数组+离线处理,对所有的w离散化处理,边dfs边使用树状数组更新左右w的情况.思路2:主席树,边bfs边建树.结点信息存储cnt,然后在线查询.树状数组. /* 4605 */ #incl ...
- poj2823Sliding Window(线段树求最值)
链接 裸线段树 这题时间卡的挺棒 #include <iostream> #include<cstdio> #include<cstring> #include&l ...
- 转 Android adb root权限
永久root带文件 因为开发需要,我经常会用到adb这个工具(Android Debug Bridge),我们都知道adb shell默认是没有root权限的,修改系统文件就很不方便了,adb pus ...
- 根据block取出页号buf_block_get_page_no
/*********************************************************************//** Gets the page number of a ...