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; }
posted on 2013-12-02 23:45 keep trying 阅读(310) 评论(0) 编辑 收藏 举报