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;
    }
  • 相关阅读:
    全排列(求所有情况的个数)--10--全排列--蓝桥杯凑算式和leetcode46全排列
    DFS+BFS(广度优先搜索弥补深度优先搜索遍历漏洞求合格条件总数)--09--DFS+BFS--蓝桥杯剪邮票
    Powermock2.0.0 详细 总结
    Springboot 前后端数据传输 常见误区
    idea src下源文件和class编译文件不一致
    java对象clone
    数据结构-链表
    队列
    稀疏数组
    数据库隔离级别
  • 原文地址:https://www.cnblogs.com/DreamHighWithMe/p/3452819.html
Copyright © 2011-2022 走看看