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;
    }
  • 相关阅读:
    [GO]使用bufio的文件读取方式
    php开发工程师面必问题
    一位资深php程序员在北京的面试30个题目
    GIT 分支管理:创建与合并分支、解决合并冲突
    linux下挂在u盘,移动硬盘的方法,转移服务器资料的时候,使用移动硬盘什么最方便了
    php后台对接ios,安卓,API接口设计和实践完全攻略,涨薪必备技能
    navicat 官方使用手册,中文版,快捷键大全
    Memcached之缓存雪崩,缓存穿透,缓存预热,缓存算法
    Memcache 笔记(2)
    Memcache笔记(1)
  • 原文地址:https://www.cnblogs.com/DreamHighWithMe/p/3454914.html
Copyright © 2011-2022 走看看