例题8-1 UVA
来源:互联网 发布:win7激活 知乎 编辑:程序博客网 时间:2024/05/21 22:54
Stacks of Flapjacks UVA - 120
/*算法竞赛入门 LRJ 例题8-1 UVA - 120*/#include<iostream>#include<cstdio>#include<cstring>#include<stack>#include<map>#include<queue>#include<cmath>#include<algorithm>#include<deque>typedef long long LL;using namespace std;#pragma comment(linker, "/STACK:102400000,102400000")const double eps = 1e-6;const int INF=0x3f3f3f3f;const int N = 1010;const int PI = acos(-1.0);int a[N],b[N];bool cmp(int x,int y){ return x > y;}void handle(int l,int r){ while(l < r) { int temp = a[l]; a[l] = a[r]; a[r] = temp; l++; r--; }}int main(){ int n = 0; char c; while(~scanf("%d%c",&a[++n],&c)) { while(c == ' ') scanf("%d%c",&a[++n],&c); for(int i = 1 ;i <= n; i++) { // b[i] = a[i]; if(i == n) printf("%d\n",a[i]); else printf("%d ",a[i]); } handle(1,n); for(int i = 1 ;i <= n; i++) b[i] = a[i]; sort(b+1,b+n+1,cmp); for(int i = 1; i <= n; i++) { //printf("%d ",b[i]); if(b[i] == a[i]) continue; int temp; for(int j = i+1; j <= n; j++) if(b[i] == a[j]) temp = j; if(temp != n) { printf("%d ",temp); handle(temp,n); temp = n; } printf("%d ",i); handle(i,temp); } printf("0\n"); n = 0; } return 0;}
0 0
- 例题8-1 UVA
- 例题8-1 煎饼 UVa 120
- 紫书动规 例题9-8 UVA
- uva 10474 例题5-1
- 例题9-1 UVa 1025
- 紫书动规 例题9-1 UVA
- UVa #120 Stacks of Flapjacks (例题8-1)
- UVa #10603 Fill (例题7-8)
- UVa #11134 Fabled Rooks (例题8-4)
- UVa #11572 Unique Snowflakes (例题8-7)
- UVa #714 Copying Books (例题8-10)
- UVa #10954 Add All (例题8-11)
- UVa #12627 Erratic Expansion (例题8-12)
- UVa #12174 Shuffle (例题8-15)
- UVa #1607 Gates (例题8-14)
- UVa #1625 Color Length (例题9-8)
- UVa #11082 Matrix Decompressing (例题11-8)
- 例题8-2 联合国大楼 UVa 1605
- python连续赋值可能引发的错误
- Linux(4)-压缩和解压缩命令
- Python 正则表达式
- 决策树的简单实现
- A
- 例题8-1 UVA
- xdoj 1190: 虢莔薅参加运动会
- 0欧姆电阻的作用
- 刷题-CC150-Java实现
- Codeforces gym 101102 D 单调栈
- POJ2080简单模拟
- Linux基础学习笔记之文件类型
- 网络编程基础
- Javascript基础学习(二)