宝石游戏
来源:互联网 发布:mac地址一样 编辑:程序博客网 时间:2024/04/28 12:15
点击打开链接
Jewelry
TimeLimit: 1 Second MemoryLimit: 32 Megabyte
Totalsubmit: 77 Accepted: 25
Description
The jewelry game is an interesting game. this game is run in a box of 13*6. While playing the game, it is given jewelrys with color red, blue, yellow, orange, green and purple. When any color of jewelry is 3 or more than 3 in direction of vertical, horizontal and diagonal these jewelry can be eliminated.
The game's screenshoot:
Now given a status of current, and a group of new stone, please tell that when the stones finally reach the buttom, what's the status of the game?
Input
The first line contain a integer n, indicate there will be n test case.
Each test case contain a table of character s whit 13 rows and 6 column, character B means jewelry of color blue , and R means a red one, O means a orange one, Y means a yellow one, G means a green one, P means a purple one. character W means there is no jewelry in this position.
Then followed 3 lines, each line contains a character, all this three line indicate the new coming jewelrys.
Finally is a integer m (1<=m<=6), indicate the position of new coming jewelrys.
Output
To each test case, output the state of the game when the new comming jewelrys reachd the buttom.
Sample Input
1
WWWWWW
WWWWWW
WWWWWW
WWWWWW
WWWWWW
WWWWWW
WWWWWW
WWWWWW
WWWWWW
WWWWWW
BBWWWW
BBWWWW
OOWWWW
B
B
Y
3
Sample Output
WWWWWW
WWWWWW
WWWWWW
WWWWWW
WWWWWW
WWWWWW
WWWWWW
WWWWWW
WWWWWW
WWWWWW
WWWWWW
WWWWWW
OOYWWW
1,首先把宝石掉入方框。
2,判断能否有宝石可以消去,并把能够消去的宝石的位置标记好。
3,消去标记好的宝石。
重复2,3步骤即可求出解。
#include<stdio.h>#include<string.h>#include<stdlib.h>#define H 13#define W 6#define JH 3#define JW 1int dir[8][2]={-1,0,0,-1,1,0,0,1,-1,-1,-1,1,1,1,1,-1};char table[H+1][W+1],newj[JH][JW];int isW[H][W];bool flag;void downOp(){ int i,j,x; for(j=0;j<W;j++){ x = H-1; for(i=H-1;i>=0;i--){ if(isW[i][j]) continue; table[x--][j] = table[i][j]; } for(i=x;i>=0;i--) table[i][j] = 'W'; }}void search(){ flag = true; int i,j,k,t; memset(isW,0,sizeof(isW)); for(i=0;i<H;i++){ for(j=0;j<W;j++){ if(table[i][j] !='W'){ for(k=0;k<8;k++){ if(i+2*dir[k][0]>=0 && i+2*dir[k][0]<13){ if(table[i+dir[k][0]][j+dir[k][1]]==table[i][j] && table[i+2*dir[k][0]][j+2*dir[k][1]]==table[i][j]){ t = 0; while(i+t*dir[k][0]>=0 && i+t*dir[k][0]<13 && table[i+t*dir[k][0]][j+t*dir[k][1]]==table[i][j]){ isW[i+t*dir[k][0]][j+t*dir[k][1]] = 1; t++; } flag = false; } } } } } } if(!flag) downOp();}int main(){ int T,i,j,k; int l,h; scanf("%d",&T); while(T--){ for(i=0;i<H;i++) scanf("%s",table[i]); for(i=0;i<JH;i++) scanf("%s",newj[i]); scanf("%d",&l);l--; for(i=H-1;i>=0;i--){ if(table[i][l] == 'W'){ h = i; break; } } for(i=h-JH+1;i<=h;i++) table[i][l] = newj[i-(h-JH+1)][0]; flag = false; while(!flag) search(); for(i=0;i<H;i++){ for(j=0;j<W;j++) printf("%c",table[i][j]); printf("\n"); } } return 0;}
- 宝石游戏
- Unity2D游戏入门教程(一)宝石迷阵(2)生成宝石地图
- Unity2D游戏入门教程(一)宝石迷阵(5)消除宝石
- Unity2D游戏入门教程(一)宝石迷阵(6)宝石下落
- J2ME开发手机游戏:宝石方块
- cocos2dx CrystalCraze 宝石消除游戏 解析(一)
- cocos2dx CrystalCraze 宝石消除游戏 解析(二)
- Splendor宝石游戏的策略分析
- Unity2D游戏入门教程(一)宝石迷阵(7)游戏结束
- Unity2D游戏入门教程(一)宝石迷阵(4)选择并交换宝石
- 对对碰(宝石迷阵 Bejeweled)游戏求解算法
- 用HTML5来开发一款Android本地游戏---宝石碰碰
- 宝石碰碰:HTML5开发Android本地化App游戏案例
- 宝石碰碰:HTML5开发Android本地化App游戏案例
- 宝石商人(2016网易游戏校招笔试)
- 玩游戏学编程:CodeCombat中国新活动[宝石争霸赛]
- Unity 3D 萌萌哒三消游戏《宝石消消乐》完整源码
- Unity2D游戏入门教程(一)宝石迷阵(1)创建项目
- NYOJ 60 谁获得了最高奖学金
- XML文件定义约束
- Lua学习笔记 VC6下编译Lua源码
- java android split() 方法 split("||") split("|") 需要转义 为 split("\\|")
- Android软键盘与back事件
- 宝石游戏
- JS省市联动菜单代码
- VS2010 找不到Silverlight Unit Test Application 工程选项
- Lua
- DB2的体系层次结构
- C++语言笔记系列之三——类的定义以及private、public、protected访问权限
- cppunit调研手册
- 如何解决Rational Rose无法启动问题
- 【java】向文本文件中写入随机整数(供测试)