101 - The Blocks Problem
来源:互联网 发布:淘宝里面我的店铺在哪 编辑:程序博客网 时间:2024/05/17 03:00
#include<stdio.h>#include<algorithm>#include<string>#include<stdlib.h>#include<math.h>#include<ctype.h>#include<string.h>#include<time.h>#include<iostream>#include<sstream>#include<vector>using namespace std;int n;vector<int> pile[30];void search(int a,int &ha,int &pa){ for(pa=0;pa<n;pa++) for(ha=0;ha<pile[pa].size();ha++) if(pile[pa][ha]==a) return;}void guiwei(int p,int h){ int i; for(i=h+1;i<pile[p].size();i++) pile[pile[p][i]].push_back(pile[p][i]); pile[p].resize(h+1);}void banyun(int pa,int ha,int pb){ int i; for(i=ha;i<pile[pa].size();i++) pile[pb].push_back(pile[pa][i]); pile[pa].resize(ha);}void printf(){ int i,j; for(i=0;i<n;i++) { printf("%d:",i); for(j=0;j<pile[i].size();j++) printf(" %d",pile[i][j]); printf("\n"); }}int main(){ int i,j,k; int a,b; string s1,s2; cin>>n; for(i=0;i<n;i++) pile[i].push_back(i); while(1) { cin>>s1; if(s1=="quit") break; cin>>a>>s2>>b; int ha,hb,pa,pb; search(a,ha,pa); search(b,hb,pb); if(pa==pb) continue; if(s1=="move"&&s2=="onto") {guiwei(pa,ha);guiwei(pb,hb);} if(s1=="move"&&s2=="over") guiwei(pa,ha); if(s1=="pile"&&s2=="onto") guiwei(pb,hb); banyun(pa,ha,pb); } printf(); return 0;}
0 0
- 101 - The Blocks Problem
- 101 - The Blocks Problem
- 101 - The Blocks Problem
- 101 - The Blocks Problem
- 101 - The Blocks Problem
- 101 - The Blocks Problem
- 101 - The Blocks Problem
- 101 - The Blocks Problem
- 101 - The Blocks Problem
- 101 - The Blocks Problem
- 101 - The Blocks Problem
- 101The Blocks Problem
- 101 - The Blocks Problem
- uva 101 the blocks problem
- uva 101 the blocks problem
- UVaOJ 101 - The Blocks Problem
- UVa 101 The Blocks Problem
- uva 101 - The Blocks Problem
- ValueError: can't find recovery API version in input target-files
- 联想昭阳E4430G触摸板无法禁用
- uva 1508 - Equipment(暴力+枚举子集)
- java 多线程
- Mysql从客户端连接服务器连不上的问题
- 101 - The Blocks Problem
- Android 应用程序退出后不在运行列表中显示的方法
- MySQL 清空所有的bin-log日志
- IOS之同步请求、异步请求、GET请求、POST请求
- Linux下检测FTP服务并开启FTP服务
- css3--我们太阳系
- Bug驱动开发(Bug-driven development)
- java性能优化(1)---HotSpot VM 32位和64位的区别
- Python学习10:序列使用