zoukankan      html  css  js  c++  java
  • ZOJ 3465 The Hive



    The Hive

    Time Limit: 2 Seconds      Memory Limit: 65536 KB

    There is a hive in the village. Like this. There are 9 columns (from A to I) in this hive. Different column may have the different number of grids. Every grid has its own coordinate, which is form by a uppercase letter and a digit. The uppercase letter discribes which column the grid is, the digit discribes which row the grid is.

    ZOJ 3465 The Hive - qhn999 - 码代码的猿猿
    As the figure shows, column A has 7 grids, column B has 8 grids, column C has 9 grids, column D has 10 grids, column E has 11 grids, column F has 10 grids, column G has 9 grids, column H has 8 grids, column I has 7 grids. The grid in the bottom has the lowest row coordinate which is 0.

    There are 26 kinds of honey. At the beginning, all grids in the hive are empty. Everyday, the bee in this hive will drop a kind of honey from the top of one of these 9 columns. The lowest empty grid of this column will be filled with this kind of honey. And if the grid under it adjacently has the same kind of honey as it did, these two grids will generate a candy. And these two grids will be emptyimmediately.

    ZOJ 3465 The Hive - qhn999 - 码代码的猿猿

    Because these columns only have a few grids, they may be full one day. If the column the bee drops on is full, this drop will not affect the hive.

    Input

    There are multiple cases (<20).

    The first line containing an integer n (1 <= n <= 10000) indicates that the bee will work for n days. Following n lines, each line contains two charater. The fisrt one indicates which column will the bee drop the honey, the second charater indicates which kind of honey does the bee drop that day.

    Output

    First,print one line in the form "The number of candy is num_of_candy.". 
    And then, display the hive. Extra space at the end of line is not allowed.

    Sample Input

    5AEBHCIDFAE

    Sample Output

    The number of candy is 1.
             _
           _/ \_
         _/ \_/ \_
       _/ \_/ \_/ \_
     _/ \_/ \_/ \_/ \_
    / \_/ \_/ \_/ \_/
    \_/ \_/ \_/ \_/ \_/
    / \_/ \_/ \_/ \_/
    \_/ \_/ \_/ \_/ \_/
    / \_/ \_/ \_/ \_/
    \_/ \_/ \_/ \_/ \_/
    / \_/ \_/ \_/ \_/
    \_/ \_/ \_/ \_/ \_/
    / \_/ \_/ \_/ \_/
    \_/ \_/ \_/ \_/ \_/
    / \_/ \_/ \_/ \_/
    \_/ \_/ \_/ \_/ \_/
    / \_/ \_/ \_/ \_/
    \_/H\_/ \_/ \_/ \_/
      \_/I\_/ \_/ \_/
        \_/F\_/ \_/
          \_/ \_/
            \_/


    Author: LIANG,Jiaxing
    Contest: ZOJ Monthly, January 2011


    #include <iostream>
    #include <cstdio>
    #include <cstring>

    using namespace std;

    char hive[9][12];
    int top[9];
    const int hi[9]={6,7,8,9,10,9,8,7,6};
    const int ku[9]={5,4,3,2,1,2,3,4,5};

    const char mpK[25][25]={
     "         _ ",
     "       _/ \_ ",
     "     \_/ \_/ \_ ",
     "   \_/ \_/ \_/ \\_ ",
     " _/ \_/ \_/ \_/ \_ ",
      "/ \_/ \_/ \_/ \_/ \ ",
     "\_/ \_/ \_/ \_/ \_/ ",
      "/ \_/ \_/ \_/ \_/ \ ",
     "\_/ \_/ \_/ \_/ \_/ ",
      "/ \_/ \_/ \_/ \_/ \ ",
     "\_/ \_/ \_/ \_/ \_/ ",
      "/ \_/ \_/ \_/ \_/ \ ",
     "\_/ \_/ \_/ \_/ \_/ ",
      "/ \_/ \_/ \_/ \_/ \ ",
     "\_/ \_/ \_/ \_/ \_/ ",
      "/ \_/ \_/ \_/ \_/ \ ",
     "\_/ \_/ \_/ \_/ \_/ ",
      "/ \_/ \_/ \_/ \_/ \ ",
     "\_/ \_/ \_/ \_/ \_/ ",
      "  \_/ \_/ \_/ \_/ ",
     "    \_/ \_/ \_/ ",
      "      \_/ \_/ ",
     "        \_/ "
    };

    int main()
    {
        int n;
    while(scanf("%d",&n)!=EOF)
    {
        int cas=0;
        memset(hive,'.',sizeof(hive));
        memset(top,0,sizeof(top));

        char mp[25][25];
        memcpy(mp,mpK,sizeof(mpK));

        char st[3];
        for(int i=0;i<n;i++)
        {
            scanf("%s",st);
            int xx=st[0]-'A';
            if(top[xx]>hi[xx]) continue;
            if(hive[xx][top[xx]-1]==st[1])   {top[xx]--;cas++;}
            else hive[xx][top[xx]++]=st[1];
        }

        for(int i=0;i<9;i++)
            for(int j=0;j<top;j++)
               mp[22-ku-j*2][i*2+1]=hive[j];

        printf("The number of candy is %d. ",cas);
        for(int i=0;i<23;i++)
             printf("%s",mp);
    }
        return 0;
    }

  • 相关阅读:
    openerp学习笔记 调用工作流
    openerp学习笔记 自定义小数精度(小数位数)
    openerp学习笔记 跟踪状态,记录日志,发送消息
    openerp学习笔记 计算字段、关联字段(7.0中非计算字段、关联字段只读时无法修改保存的问题暂未解决)
    openerp学习笔记 tree视图增加复选处理按钮
    openerp学习笔记 统计、分析、报表(过滤条件向导、分组报表、图形分析、比率计算、追加视图排序)
    openerp学习笔记 视图样式(表格行颜色、按钮,字段只读、隐藏,按钮状态、类型、图标、权限,group边距,聚合[合计、平均],样式)
    openerp学习笔记 计划动作、计划执行(维护计划)
    银行前置以及银行核心系统
    什么是报文
  • 原文地址:https://www.cnblogs.com/CKboss/p/3350927.html
Copyright © 2011-2022 走看看