zoukankan      html  css  js  c++  java
  • I

    I - The Hive
    Time Limit:2000MS     Memory Limit:65536KB     64bit IO Format:%lld & %llu

    Description

    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.

    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 empty immediately.

    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

    5
    AE
    BH
    CI
    DF
    AE
    

    Sample Output

    The number of candy is 1.
             _
           _/ \_
         _/ \_/ \_
       _/ \_/ \_/ \_
     _/ \_/ \_/ \_/ \_
    / \_/ \_/ \_/ \_/ 
    \_/ \_/ \_/ \_/ \_/
    / \_/ \_/ \_/ \_/ 
    \_/ \_/ \_/ \_/ \_/
    / \_/ \_/ \_/ \_/ 
    \_/ \_/ \_/ \_/ \_/
    / \_/ \_/ \_/ \_/ 
    \_/ \_/ \_/ \_/ \_/
    / \_/ \_/ \_/ \_/ 
    \_/ \_/ \_/ \_/ \_/
    / \_/ \_/ \_/ \_/ 
    \_/ \_/ \_/ \_/ \_/
    / \_/ \_/ \_/ \_/ 
    \_/H\_/ \_/ \_/ \_/
      \_/I\_/ \_/ \_/
        \_/F\_/ \_/
          \_/ \_/
            \_/
    
    
     
    const int INF = 1000000000;
    const double eps = 1e-8;
    const int maxn = 30000;
    char hive[100][200];
    char op[10];
    int change(char t)
    {
        return 2*(t - 'A' + 1);
    }
    int d[100],u[100],en[100];
    void init()
    {
        u[2] = 34;u[4] = 36;u[6] = 38;u[8] = 40;u[10] = 42;
        u[12] = 40;u[14] = 38;u[16] = 36;u[18] = 34;
        d[2] = 10;d[4] = 8;d[6] = 6;d[8] = 4;d[10] = 2;
        d[12] = 4;d[14] = 6;d[16] = 8;d[18] = 10;
    }
    int main() 
    {
       // freopen("in.txt","r",stdin);
       // freopen("ot.txt","w",stdout);
        int n;
        while(cin>>n)
        {
            init();
            int ans = 0;
            repf(i,1,90)
                repf(j,1,19)
                hive[i][j] = ' ';
    
            int s = 2;
            int e = 18;
            repd(i,9,1)
            {
                if(i%2){
                    for(int j = s;j <= e;j += 4) hive[i][j] = '_';
                }else{
                    int mark = 0;
                    for(int j = s;j <= e;j += 2) {
                        if(mark%2 == 0)
                            hive[i][j] = '/';
                        else
                            hive[i][j] = '\';
                        mark++;
                    }
                }
                en[i] = e;
                s++;e--;    
            }
    
            s = 2;
            e = 18;
            repf(i,37,45)
            {
                if(i%2){
                    for(int j = s;j <= e;j += 4) hive[i][j] = '_';
                }else{
                    int mark = 0;
                    for(int j = s;j <= e;j += 2) {
                        if(mark%2 == 0)
                            hive[i][j] = '\';
                        else
                            hive[i][j] = '/';
                        mark++;
                    }
                }
                en[i] = e;
                s++;e--;      
            }
    
            repf(i,10,36)
            {
                if(i%4 == 2)
                {
                     int mark = 0;
                     for(int j = 1;j <= 19;j += 2) {
                         if(mark%2 == 0)
                             hive[i][j] = '/';
                         else
                             hive[i][j] = '\';
                         mark++;
                     }
                     en[i] = 19;
                }
                if(i%4 == 0)
                {
                     int mark = 0;
                     for(int j = 1;j <= 19;j += 2) {
                         if(mark%2 == 0)
                             hive[i][j] = '\';
                         else
                             hive[i][j] = '/';
                         mark++;
                     }
                     en[i] = 19;
                }
                if(i%4 == 3)
                {
                    s = 4;
                    for(int j = s;j<=16;j+=4)  hive[i][j] = '_';
                    en[i] = 16;
                }
                if(i%4 == 1)
                {
                    s = 2;
                    for(int j = s;j<=18;j+=4)  hive[i][j] = '_';
                    en[i] = 18;
                }
            }
            
            repf(i,1,n)
            {
                scanf("%s",op);
                int k = change(op[0]);
                if(u[k] < d[k]) continue;
                if(hive[u[k] + 4][k] == op[1])
                {
                    ans++;
                    hive[u[k]+4][k] = ' ';
                    u[k] += 4;
                }
                else
                {
                    hive[u[k]][k] = op[1];
                    u[k] -= 4;
                }
            }
            printf("The number of candy is %d.
    ",ans);
            repf(i,1,45)
            {
                if(i%2 && i > 1)
                {
                    repf(j,1,en[i])
                    if(hive[i][j] != ' ' && hive[i - 1][j] == ' ')
                        hive[i - 1][j] =  hive[i][j];
                }
            }
            repf(i,1,45)
            {
                if(i%2 && i>1) continue;
                if(i<=8 && i!= 1) en[i]++;
                repf(j,1,en[i])
                {
                    printf("%c",hive[i][j]);
                }
                cout<<endl;
            }
        }
        return 0;
    }
  • 相关阅读:
    Unity 鼠标控制视角功能和动画播放冲突解决办法
    Unity5.6.4f1 配置WebGL教程
    动态生成圈形+文字的图片
    mysql 常用操作语句
    ideal环境maven自动下载项目依赖配置
    java调用c#dll文件配置
    项目部署到阿里云遇到数据库和访问问题解决记录
    uni-app打印
    JS将时间对象输出为(12小时制和24小时制)的字符串
    基于H5的摄像头视频的采集与传输
  • 原文地址:https://www.cnblogs.com/DreamHighWithMe/p/3452819.html
Copyright © 2011-2022 走看看