zoukankan      html  css  js  c++  java
  • 6277 Addictive Bubbles 水构造

    6277 Addictive Bubbles
    Alice is a mobile game developer. She writes a new port of the Chain Shot! game (also known as
    SameGame, Jawbreaker, Bubble Shot, etc) called Addictive Bubbles.
    The game is played on a rectangular board lled with color bubbles. On each turn player selects a
    group of adjacent bubbles of the same color. Selected bubbles are removed from the board. Bubbles
    that are no longer supported fall down. If there are empty columns, they are removed.
    The number of points scored by the move is a square of the number of bubbles in the selected group.
    For the sample turn shown on the gure, 49 points are scored.
    Turns are repeated until the board is empty. The total number of points is the sum of points scored
    on each turn.
    The blueprint of the level consists of board dimensions and the number of bubbles of each color.
    Your task is to help Alice write a bonus level generator. Given the blueprint, generator must produce
    a level that allows a skillful player to score the maximum possible number of points compared to all
    levels with the same blueprint.
    Input
    The input will contain several test cases, each of them as described below.
    The input contains the blueprint.
    The rst line of the input contains three positive integers h, w and c | number of rows and columns
    of the board, and the number of colors (1  h; w  10; 1  c  9).
    The second line of the input contains c positive integer numbers | the number of bubbles of each
    color. The total number of bubbles is h  w.
    Output
    For each test case, the output must follow the description below.
    Output the designed level | a h w matrix of characters. The bubbles of the rst color must be
    denoted by `1', the second color | by `2', etc.
    Note for the sample:
    A sequence of turns, yielding the maximum possible number of points | 81:

    const int INF = 1000000000;
    const double eps = 1e-8;
    const int maxn = 30;
    int co[10];
    int ans[maxn][maxn];
    int main() 
    {
        //freopen("in.txt","r",stdin);
        int h,w,c;
        while(cin>>h>>w>>c)
        {
            repf(i,1,c)
                scanf("%d",&co[i]);
            int k = 1;
            int mark = 0;
            repd(i,h,1)
            {
                if(mark%2 == 0)
                {
                    repf(j,1,w)
                    {
                        if(co[k])
                        {
                            ans[i][j] = k;
                            co[k]--;
                        }else
                        {
                            if(k < c)
                                k++;
                            ans[i][j] = k;
                            co[k]--;
                        }
                    }
                }else
                {
                    repd(j,w,1)
                    {
                        if(co[k])
                        {
                            ans[i][j] = k;
                            co[k]--;
                        }else
                        {
                            if(k < c)
                                k++;
                            ans[i][j] = k;
                            co[k]--;
                        }
                    }
                }
                mark++;
            }
            
            repf(i,1,h)
            {
                repf(j,1,w)
                    printf("%d",ans[i][j]);
                cout<<endl;
            }
        }
        return 0;
    }
  • 相关阅读:
    vue自定义指令使用注意事项
    es6新增方法---实用
    webpack和gulp的区别
    OSI 5层协议,socket,从协议角度看网络通信
    网络通信流程
    数据相关的模块
    一些模块
    面向对象
    ATM作业
    XML模块增删改查基本操作
  • 原文地址:https://www.cnblogs.com/DreamHighWithMe/p/3454914.html
Copyright © 2011-2022 走看看