• 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;
    }
  • 相关阅读:
    Iscroll滑动无效
    原生js 无缝滚动组件
    原生 js dialog弹窗组件
    html5 历史管理
    html5拖拽属性
    highcharts 数据图设置X轴间隔显示效果
    highcharts柱状图含有正负柱设置不同颜色的方法
    移动端滑动插件 swiper
    千分位添加和去掉方法
    dubbo常用类和路径
  • 原文地址:https://www.cnblogs.com/DreamHighWithMe/p/3454914.html
Copyright © 2020-2023  润新知