2014-2015 ACM-ICPC, NEERC, Moscow Subregional Contest A. Advanced 2048
2 seconds
256 megabytes
standard input
standard output
Only lazy did not play the 2048 game last year. Soon, the secret of success had been revealed and interest to the game has faded. Nevertheless, the developers are now working on new modifications to the game. One of the prominent directions for the future development was the increased size of the game field and the increased final score.
However, in order to pick the optimal field size, it is required to emulate the gameplay many times on the fields of different sizes to estimate the number of moves needed to reach the goal under new conditions, and also to estimate the possible score values.
You are to write a program that will determine the final score given the description of a game session: field size, placement of the tiles and their values, the sequence of the player's moves and the description of all new tiles appearing on the field.
For those who are newbies to the popular game, the game rules are the following. 2048 is played on a N × N tile grid, with numbered tiles that all slide when a player moves them using the four arrow keys. After every turn, a new tile will randomly appear in an empty spot on the board with a value of either 2 or 4. Tiles slide as far as possible in the chosen direction until they are stopped by either another tile or the edge of the grid. If two tiles of the same number collide while moving, they will merge into a tile with the total value of the two tiles that collided. The resulting tile cannot merge with another tile again in the same move. The tile moves and mergers are resolved from the first tile to the last one (in terms of movement direction) consequently. For example, after moving to the right, the row "2 2 _ 2 _" turns into "_ _ _ 2 4", and the row "2 2 2 2 2 2" turns into "_ _ _ 4 4 4".
The player's score starts at zero, and is incremented whenever two tiles combine by the value of the new tile.
The first line of input contains an integer N, the size of the field (4 ≤ N ≤ 100). The second line of input contains an integer K, the number of tiles already on the field (0 ≤ K ≤ N2). In each of the next K lines, three integers are given to describe the tiles on the field: a number written in the tile (one of the powers of two from first (2) to tenth (1024)) and the tile coordinates on the field: row and column. Rows are numbered from one starting from the top, and columns are numbered from one starting from the left. It is guaranteed that the given tiles occupy K different cells of the grid.
After that, an integer L is given on a separate line: the number of player's moves in a game session (0 ≤ L ≤ 10 000). The next L lines contain descriptions of the player's moves in their order, one description per line. A description of a move starts with one of the characters "L" (left), "R" (right), "U" (up) or "D" (down). Then follow three integers separated by single spaces. They define the new tile that appeared on the field after the player's move with the value of either 2 or 4 and the coordinates of the tile: row and column. It is guaranteed that the new tile is placed on an empty tile of the field after each player's move.
Output a single integer: the final score in the game which is described in the input.
6
5
2 1 2
2 1 3
4 1 5
4 1 6
2 3 1
2
L 4 2 1
U 2 6 2
20
4
4
1024 1 1
1024 1 2
1024 2 1
1024 2 2
2
D 4 1 1
R 4 1 1
8192 题意:模拟一下2048的程序,问最后的分值。
分析:模拟
2014-2015 ACM-ICPC, NEERC, Moscow Subregional Contest A. Advanced 2048的更多相关文章
- 2018-2019 ICPC, NEERC, Southern Subregional Contest
目录 2018-2019 ICPC, NEERC, Southern Subregional Contest (Codeforces 1070) A.Find a Number(BFS) C.Clou ...
- Codeforces 2018-2019 ICPC, NEERC, Southern Subregional Contest
2018-2019 ICPC, NEERC, Southern Subregional Contest 闲谈: 被操哥和男神带飞的一场ACM,第一把做了这么多题,荣幸成为7题队,虽然比赛的时候频频出锅 ...
- 2016 NEERC, Moscow Subregional Contest K. Knights of the Old Republic(Kruskal思想)
2016 NEERC, Moscow Subregional Contest K. Knights of the Old Republic 题意:有一张图,第i个点被占领需要ai个兵,而每个兵传送至该 ...
- 2018-2019 ICPC, NEERC, Southern Subregional Contest (Online Mirror) Solution
从这里开始 题目列表 瞎扯 Problem A Find a Number Problem B Berkomnadzor Problem C Cloud Computing Problem D Gar ...
- 2010-2011 ACM-ICPC, NEERC, Moscow Subregional Contest Problem D. Distance 迪杰斯特拉
Problem D. Distance 题目连接: http://codeforces.com/gym/100714 Description In a large city a cellular ne ...
- 2010-2011 ACM-ICPC, NEERC, Moscow Subregional Contest Problem C. Contest 水题
Problem C. Contest 题目连接: http://codeforces.com/gym/100714 Description The second round of the annual ...
- 2016-2017 ACM-ICPC, NEERC, Moscow Subregional Contest Problem L. Lazy Coordinator
题目来源:http://codeforces.com/group/aUVPeyEnI2/contest/229511 时间限制:1s 空间限制:512MB 题目大意: 给定一个n 随后跟着2n行输入 ...
- Codeforces1070 2018-2019 ICPC, NEERC, Southern Subregional Contest (Online Mirror, ACM-ICPC Rules, Teams Preferred)总结
第一次打ACM比赛,和yyf两个人一起搞事情 感觉被两个学长队暴打的好惨啊 然后我一直做傻子题,yyf一直在切神仙题 然后放一波题解(部分) A. Find a Number LINK 题目大意 给你 ...
- codeforce1070 2018-2019 ICPC, NEERC, Southern Subregional Contest (Online Mirror, ACM-ICPC Rules, Teams Preferred) 题解
秉承ACM团队合作的思想懒,这篇blog只有部分题解,剩余的请前往星感大神Star_Feel的blog食用(表示男神汉克斯更懒不屑于写我们分别代写了下...) C. Cloud Computing 扫 ...
随机推荐
- hdu2108(判断凸多边形)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2108 题意: 给出一个多边形的所有顶点,判断是不是凸多边形: 思路: 判断凸多边形的方法比较多,如:若 ...
- NYOJ题目916胖子小的百宝袋
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAsQAAAL6CAIAAAC+R9cJAAAgAElEQVR4nOydO5LcvM6GzyYmn4U47o
- 三、jQuery--Ajax基础--Ajax全接触--扩展知识(跨域)
- case/casez/casex 的区分与使用
参考:http://www.cnblogs.com/poiu-elab/archive/2012/11/02/2751323.html 与 verilog数字系统设计基础 一般来说,使用最多的是CA ...
- 按键消抖-----verilog
实际系统中常用的按键大部分都是轻触式按键,如下图所示.该按键内部由一个弹簧片和两个固定触点组成,当弹簧片被按下,则两个固定触点接通,按键闭合.弹簧片松开,两个触点断开,按键也就断开了.根据这种按键的机 ...
- python中的时间处理函数
Python提供了多个内置模块用于操作日期时间,像calendar,time,datetime.time模块我在之前的文章已经有所介绍,它提供 的接口与C标准库time.h基本一致.相比于time模块 ...
- PHP 获取图像信息 getimagesize 函数
getimagesize() 函数用于获取图像尺寸,类型等信息. imagesx() 函数用于获取图像的宽度. imagesy() 函数用于获取图像的高度. getimagesize() getima ...
- Ajax 的 GET 和 POST 模式
Ajax 异步请求数据的方式有两种:GET 和 POST. 如果是 GET 模式,则直接将数据放置到异步请求的 URL 地址中,而 send() 方法不发送任何数据: var queryString ...
- Instagram的持续部署技术
Instagram最近发表了一篇关于他们的持续部署(CD)管道的文章,持续部署管道可以让他们更快的将代码推送到生产环境,并且轻松地识别糟糕的提交和始终保持发布可用.在一段时间内以迭代的方式放在一起,其 ...
- phpcms v9中调用栏目及调用多个子栏目中的文章列表
调用一个指定栏目列表: {pc:content action="lists" catid="6" order="id DESC& ...