I - The Hive 恶心模拟

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

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.\n",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;
}

 

转载于:https://www.cnblogs.com/DreamHighWithMe/p/3452819.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值