Problem:Minesweeper Master
Google code jam Qualification Round 2014
题目链接:https://code.google.com/codejam/contest/dashboard?c=2974486#s=p2
Download:source code
#Define LEFT = R*C – M
M==R*C-1
ok.
|
C |
* |
* |
|
* |
* |
* |
|
* |
* |
* |
M<R*C-1
R==1 or C == 1
ok.
LEFT = {1}
|
C |
* |
* |
|
C |
|
* |
|
* |
R==2 or C == 2
It is ok when the LEFT are even, and so does C==2.
LEFT = {1,4,6,8,..2n} n=max(R,C);
|
C |
. |
* |
|
. |
. |
* |
|
C |
. |
* |
|
. |
*(wrong) |
* |
R>=3 && C >= 3
,,4,,6,,8,9,10,…,i,…,R*C};
LEFT = {1,4, 6,8,9,10,…,i,…,R*C}; 8<=i<=R*C; //Proved at 2.3.1
1
4
|
C |
. |
* |
* |
|
. |
. |
* |
* |
|
* |
* |
* |
* |
6
|
C |
. |
. |
* |
|
. |
. |
. |
* |
|
* |
* |
* |
* |
8
|
C |
. |
. |
. |
|
. |
. |
. |
. |
|
* |
* |
* |
* |
9
|
C |
. |
. |
* |
|
. |
. |
. |
* |
|
. |
. |
. |
* |
10
|
C |
. |
. |
. |
|
. |
. |
. |
. |
|
. |
. |
* |
* |
11
|
C |
. |
. |
. |
|
. |
. |
. |
. |
|
. |
. |
. |
* |
12
|
C |
. |
. |
. |
|
. |
. |
. |
. |
|
. |
. |
. |
. |
Prove that i is from 8 to R*C one by one
Each i from 8 to R*C can be
firstly
i = 8
|
C |
1 |
1 |
* |
* |
* |
* |
|
1 |
1 |
1 |
* |
* |
* |
* |
|
1 |
1 |
* |
* |
* |
* |
* |
|
* |
* |
* |
* |
* |
* |
* |
secondly
if we want to goto i(8 < i <= R*C)
8 < i <= 8 + 2 * (R-2)
0 == i % 2
Only set the first and second columns is enough.
Add two each time.
|
C |
0 |
1 |
* |
* |
* |
* |
|
0 |
0 |
1 |
* |
* |
* |
* |
|
0 |
1 |
* |
* |
* |
* |
* |
|
0 |
1 |
* |
* |
* |
* |
* |
|
1 |
1 |
* |
* |
* |
* |
* |
|
* |
* |
* |
* |
* |
* |
* |
0 != i % 2
Set the first and second columns to (i-1).
And set [2][2]
|
C |
0 |
1 |
* |
* |
* |
* |
|
0 |
0 |
1 |
* |
* |
* |
* |
|
0 |
1 |
1 |
* |
* |
* |
* |
|
0 |
1 |
* |
* |
* |
* |
* |
|
1 |
1 |
* |
* |
* |
* |
* |
|
* |
* |
* |
* |
* |
* |
* |
8 + 2 * (R-2) < i <= 2 * (R+C-2)
Set full of the first and second columns
|
C |
0 |
1 |
* |
* |
* |
* |
|
0 |
1 |
1 |
* |
* |
* |
* |
|
0 |
1 |
* |
* |
* |
* |
* |
|
0 |
1 |
* |
* |
* |
* |
* |
|
0 |
1 |
* |
* |
* |
* |
* |
|
0 |
1 |
* |
* |
* |
* |
* |
0 == i % 2
Only set the first and second rows is enough.
Add two each time.
|
C |
0 |
0 |
0 |
1 |
* |
* |
|
0 |
1 |
1 |
1 |
1 |
* |
* |
|
0 |
1 |
* |
* |
* |
* |
* |
|
0 |
1 |
* |
* |
* |
* |
* |
|
0 |
1 |
* |
* |
* |
* |
* |
|
0 |
1 |
* |
* |
* |
* |
* |
0 != i % 2
Set the first and second columns to (i-1).
And set [2][2]
|
C |
0 |
0 |
0 |
1 |
* |
* |
|
0 |
0 |
1 |
1 |
1 |
* |
* |
|
0 |
1 |
1 |
* |
* |
* |
* |
|
0 |
1 |
* |
* |
* |
* |
* |
|
0 |
1 |
* |
* |
* |
* |
* |
|
0 |
1 |
* |
* |
* |
* |
* |
2 * (R+C-2) < i <= R*C
|
C |
0 |
0 |
0 |
0 |
0 |
0 |
|
0 |
1 |
1 |
1 |
1 |
1 |
1 |
|
0 |
1 |
* |
* |
* |
* |
* |
|
0 |
1 |
* |
* |
* |
* |
* |
|
0 |
1 |
* |
* |
* |
* |
* |
|
0 |
1 |
* |
* |
* |
* |
* |
2 * (R+C-2) < i <= 2*(R+C-2)+(R-2)*(column-2)
3 <= column <= C;
Each column from the third to the last left (R-2) positions.
- 2 * (R+C-2) < i <= 2*(R+C-2)+(R-2)*(3-2)
Set the third column (i-2*(R+C-2)) from [2][2] to [R-1][2]
|
3 |
||||||
|
C |
0 |
0 |
0 |
0 |
0 |
0 |
|
0 |
0 |
1 |
1 |
1 |
1 |
1 |
|
0 |
0 |
1 |
* |
* |
* |
* |
|
0 |
1 |
1 |
* |
* |
* |
* |
|
0 |
1 |
* |
* |
* |
* |
* |
|
0 |
1 |
* |
* |
* |
* |
* |
- 2 * (R+C-2) < i <= 2*(R+C-2)+(R-2)*(4-2)
Set full of the third column.
Set the fourth column (i-2*(R+C-2) – (R-2)) from [2][3] to [R-1][3]
|
3 |
4 |
|||||
|
C |
0 |
0 |
0 |
0 |
0 |
0 |
|
0 |
0 |
0 |
1 |
1 |
1 |
1 |
|
0 |
0 |
0 |
1 |
* |
* |
* |
|
0 |
0 |
0 |
1 |
* |
* |
* |
|
0 |
0 |
1 |
1 |
* |
* |
* |
|
0 |
0 |
1 |
* |
* |
* |
* |
- 2 * (R+C-2) < i <= 2*(R+C-2)+(R-2)*(k-2)
Set full of the third to (k-1) columns.
Set the k column (i-2*(R+C-2) – (k-3)(R-2)) from [2][k-1] to [R-1][k-1]
|
3 |
k-1 |
k |
||||
|
C |
0 |
0 |
0 |
0 |
0 |
0 |
|
0 |
0 |
0 |
0 |
0 |
1 |
1 |
|
0 |
0 |
0 |
0 |
0 |
1 |
* |
|
0 |
0 |
0 |
0 |
1 |
1 |
* |
|
0 |
0 |
0 |
0 |
1 |
* |
|
|
0 |
0 |
0 |
0 |
1 |
* |
Problem:Minesweeper Master的更多相关文章
- Google Code Jam 2014 资格赛:Problem C. Minesweeper Master
Problem Minesweeper is a computer game that became popular in the 1980s, and is still included in so ...
- The 2015 China Collegiate Programming Contest A. Secrete Master Plan hdu5540
Secrete Master Plan Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 65535/65535 K (Java/Othe ...
- hdu 5540 Secrete Master Plan(水)
Problem Description Master Mind KongMing gave Fei Zhang a secrete master plan stashed × matrix, but ...
- ACM Secrete Master Plan
Problem Description Master Mind KongMing gave Fei Zhang a secrete master plan stashed in a pocket. T ...
- HDU-5540 Secrete Master Plan
Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 65535/65535 K (Java/Others)Total Submission( ...
- Master of Subgraph
Problem E. Master of SubgraphYou are given a tree with n nodes. The weight of the i-th node is wi. G ...
- 2017ccpc 杭州Master of Sequence
Problem K. Master of SequenceTherearetwosequencesa1,a2,··· ,an, b1,b2,··· ,bn. LetS(t) =∑n i=1⌊t−bi ...
- Google Code Jam 2014 Qualification 题解
拿下 ABD, 顺利晋级, 预赛的时候C没有仔细想,推荐C题,一个非常不错的构造题目! A Magic Trick 简单的题目来取得集合的交并 1: #include <iostream> ...
- HDU5477(模拟)
A Sweet Journey Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)T ...
随机推荐
- 【百题留念】hdoj 1524 A Chess Game(dfs + SG函数应用)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1524 #include<stdio.h> #include<cstring> ...
- C10K problem
什么是C10K问题 1W个客户端连接上一个server,客户不定时的发送请求. I/O策略 软件架构 1.单线程解决多重I/O调用 不要使用阻塞/同步的调用,如果非要这么做,那就采用多进程或者 ...
- cdoj 80 Cube 水题
Cube Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.uestc.edu.cn/#/problem/show/80 Descrip ...
- 2015UESTC 暑假集训总结
day1: 考微观经济学去了…… day2: 一开始就看了看一道题目最短的B题,拍了半小时交了上去wa了 感觉自己一定是自己想错了,于是去拍大家都过的A题,十分钟拍完交上去就A了 然后B题写了一发暴力 ...
- C#操作Excel(1)Excel对象模型
Excel对象模型 (.Net Perspective) 本文主要针对在Visual Studio中使用C# 开发关于Excel的应用程序 本文的PDF下载地址:C#操作Excel2007.pdf ...
- Java IO之File
FILE类是用来实现获取文件.文件夹的类库工具,File并不是像类名所表示的那样仅仅是用来表示文件.它还能够用来表示文件夹. 所以能够用File来获取一个文件夹下的全部文件,甚至是文件夹中的文件. 一 ...
- TP复习
第一课,三步骤 1,.名称 2.路径 3.引用核心文件 4,.公用的可以建立public upload css 等 第二课 uRL四中模式 ~ActionClass.php 一.什么是MVC / ...
- JAVA正则表达式语法大全
[正则表达式]文本框输入内容控制 整数或者小数:^[0-9]+\.{0,1}[0-9]{0,2}$ 只能输入数字:"^[0-9]*$". 只能输入n位的数字:"^\d{n ...
- Cocos2d-html5 笔记4: 粒子
今天看了cocos2d-html5里面的粒子系统相关的代码,首先看了代码中引用的两篇文章, 这两篇文章google上都可以搜到pdf的. The Ocean Spray in Your Face [j ...
- mysql常用命令大全 mysql常用命令总结
原文地址:http://www.jbxue.com/db/12472.html 本文介绍下,mysql中常用的一些命令,包括创建与修改数据库.数据库中的表,mysql的权限管理命令grant.revo ...