这是一道很好的模拟题,用vector<int> p[maxn],建立模型,映射为maxn个堆。主要要掌握vector模拟堆操作的简单方法。
接下来得思路是自顶向下的方式,逐步完善程序。首先根据提议列出下表。
1.move a onto b
clear_above(a) && clear_above(b);
insert a above b;

2.move a over b
clear(a)
insert a above bs

3.pile a onto b
clear(b)
insert as above b

4.pile a over b
insert as above bs

观察可以提取出move的话必有clear_above(a)、onto必有clear_above(b).
而insert 动作不管b是在p[b]的顶部还是外部。都是p[b].push_back(a或a以上的木块)
所以可以抽取成pile_into(pa, ha, pb);

考虑完这些,开始写框架。如下

 vector<      
     
     
          scanf("%d", &n);
              a[i].push_back(i);
     }
     
                       cin >> ba >> s2 >> bb;
                                             
                           pile_into(pa, ha, pb);
     }
     
     print();
      }

接下来,完成程序其它部分,按照框架的意思,逐步完善。如下

 }
 
      
              
                                        }
         
     }
      }
 
                    
                  a[b].push_back(b);
         
     }
     a[p].resize(h + 1);
 }
 
      
          
              a[pb].push_back(a[pa][i]);
     }
     a[pa].resize(ha);
 }

uva 101 by sixleaves的更多相关文章

  1. UVa 101 The Blocks Problem Vector基本操作

    UVa 101 The Blocks Problem 一道纯模拟题 The Problem The problem is to parse a series of commands that inst ...

  2. 木块问题(The Blocks Problem,Uva 101)

    不定长数组:vector vector就是一个不定长数组.不仅如此,它把一些常用操作“封装”在了vector类型内部. 例如,若a是一个vector,可以用a.size( )读取它的大小,a.resi ...

  3. Uva 101 -- the block problem

    Uva 101 the block problem 题目大意: 输入n,得到编号为0~n-1的木块,分别摆放在顺序排列编号为0~n-1的位置.现对这些木块进行操作,操作分为四种. 1.move a o ...

  4. UVa 101 - The Blocks Problem(积木问题,指令操作)

    题目来源:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=3&pa ...

  5. uva 101 POJ 1208 The Blocks Problem 木块问题 vector模拟

    挺水的模拟题,刚开始题目看错了,poj竟然过了...无奈.uva果断wa了 搞清题目意思后改了一下,过了uva. 题目要求模拟木块移动: 有n(0<n<25)快block,有5种操作: m ...

  6. UVA 101

    题意:四种操作把a和b所在的数字移动. lrj的思想很好.首先找到共同点.然后不必写四种操作.其次理解vector的方便. #include<iostream> #include<c ...

  7. UVa 101 The Blocks Problem

    题意:给出从左到右放置的n块木块(从0开始编号),再给出四种操作,再给出相应的操作,输出操作结束后每一堆木块的情况. 学习的紫书,因为每一堆的木块数是在发生变化的,所以用vector. 然后就是模拟几 ...

  8. UVa 101 (模拟) The Blocks Problem

    题意: 有n个木块及n个木块堆,初始状态是第i个木块在第i个木块堆上.对应有四种操作,然后输出最终状态. 分析: 用一个vector<int>模拟一个木块堆,进行相应操作即可. #incl ...

  9. uva 1589 by sixleaves

    坑爹的模拟题目.自己对于这种比较复杂点得模拟题的能力概述还不够,还多加练习.贴别是做得时候一直再想如何检查车中间有没有棋子,炮中间有没有棋子.到网上参考别人的代码才发先这么简单的办法,自己尽然想不到. ...

随机推荐

  1. Longest Palindromic Substring 解答

    Question Given a string S, find the longest palindromic substring in S. You may assume that the maxi ...

  2. SharePoint excel service web part 连接到 filter web part

    本文讲述SharePoint excel service web part 连接到 filter web part的一个简单应用场景. SharePoint excel service web par ...

  3. Android Call requires API level 11 (current min is 8)的解决方案

    [错误描述] 在用Eclipse开发过程中,为了兼容Android2.2和4.0以上版本,我在使用Notification类时做了2个版本的代码,代码根据系统版本不同执行相应模块,结果,等我输完代码, ...

  4. python 得到一个元素的所有下标(网友提供:http://www.oschina.net/code/snippet_212212_38917)

    def all_index(l,o): def find_index(l,o,start=0): try: index=l.index(o,start) except: index=-1 return ...

  5. Ubuntu14.04配置cuda-convnet

    转载请注明:http://blog.csdn.net/stdcoutzyx/article/details/39722999 在上一个链接中,我配置了cuda,有强大的GPU,自然不能暴殄天物,让资源 ...

  6. Laravel 安装指南

    http://www.golaravel.com/article/laravel-installation-guide/ http://laravel.com/api/4.1/ http://ding ...

  7. Filter简单介绍

    一.简单介绍 Filter也称为过滤器,WEB开发者通过Filter技术.对webserver管理的全部web资源:比如Jsp, Servlet, 静态图片文件或静态 html 文件等进行拦截.从而实 ...

  8. jquery使用load开展局部刷新没有效果

    jquery使用load开展局部刷新没有效果   jquery使用load进行局部刷新没有效果我的代码 <html><head><meta charset="u ...

  9. hdu3599 War(最大流)

    转载请注明出处: http://www.cnblogs.com/fraud/          ——by fraud War Time Limit: 2000/1000 MS (Java/Others ...

  10. Windows,Linux换行知识

    换行符在写文件的时候用得上 Linux: "\n"Windows: "\r\n" 注意:换行符一定要加上双引号,单引号是没有用的.