Google code jam Qualification Round 2014

题目链接:https://code.google.com/codejam/contest/dashboard?c=2974486#s=p2

Download:source code

word版文档下载

#Define LEFT = R*C – M

  1. M==R*C-1

ok.

C

*

*

*

*

*

*

*

*

  1. M<R*C-1

    1. R==1 or C == 1

ok.

LEFT = {1}

C

*

*

C

*

*

  1. 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)

*

  1. 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

.

.

.

.

.

.

.

.

.

.

.

  1. Prove that i is from 8 to R*C one by one

Each i from 8 to R*C can be

  1. firstly

i = 8

C

1

1

*

*

*

*

1

1

1

*

*

*

*

1

1

*

*

*

*

*

*

*

*

*

*

*

*

  1. secondly

if we want to goto i(8 < i <= R*C)

  1. 8 < i <= 8 + 2 * (R-2)
    1. 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

*

*

*

*

*

*

*

*

*

*

*

*

  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

*

*

*

*

*

*

*

*

*

*

*

*

  1. 8 + 2 * (R-2) < i <= 2 * (R+C-2)
    1. Set full of the first and second columns

C

0

1

*

*

*

*

0

1

1

*

*

*

*

0

1

*

*

*

*

*

0

1

*

*

*

*

*

0

1

*

*

*

*

*

0

1

*

*

*

*

*

  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

*

*

*

*

*

  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

*

*

*

*

*

  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

*

*

*

*

*

  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.

  1. 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

*

*

*

*

*

  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

*

*

*

*

  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的更多相关文章

  1. 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 ...

  2. 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 ...

  3. hdu 5540 Secrete Master Plan(水)

    Problem Description Master Mind KongMing gave Fei Zhang a secrete master plan stashed × matrix, but ...

  4. ACM Secrete Master Plan

    Problem Description Master Mind KongMing gave Fei Zhang a secrete master plan stashed in a pocket. T ...

  5. HDU-5540 Secrete Master Plan

    Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65535/65535 K (Java/Others)Total Submission( ...

  6. 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 ...

  7. 2017ccpc 杭州Master of Sequence

    Problem K. Master of SequenceTherearetwosequencesa1,a2,··· ,an, b1,b2,··· ,bn. LetS(t) =∑n i=1⌊t−bi ...

  8. Google Code Jam 2014 Qualification 题解

    拿下 ABD, 顺利晋级, 预赛的时候C没有仔细想,推荐C题,一个非常不错的构造题目! A Magic Trick 简单的题目来取得集合的交并 1: #include <iostream> ...

  9. HDU5477(模拟)

    A Sweet Journey Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)T ...

随机推荐

  1. IAR USING PRE- AND POST-BUILD ACTIONS

    Using pre-build actions for time stamping If necessary, you can specify pre-build and post-build act ...

  2. PL/pgSQL学习笔记之四

    http://www.postgresql.org/docs/9.1/static/plpgsql-structure.html 39.2. PL/pgSQL 的结构 PL/pgSQL是一种块式结构的 ...

  3. Linux Kconfig及Makefile学习

    内核源码树的目录下都有两个文档Kconfig (2.4版本是Config.in)和Makefile.分布到各目录的Kconfig构成了一个分布式的内核配置数据库,每个Kconfig分别描述了所属目录源 ...

  4. jQuery hover事件鼠标滑过图片半透明标题文字滑动显示隐藏

    1.效果及功能说明 hover事件制作产品图片鼠标滑过图片半透明,标题文字从左到右滑动动画移动显示隐藏 2.实现原理 首先把效果都隐藏,然后定义一个伪类来触发所有的效果,接下来当触发伪类后会有一个遍历 ...

  5. iframe式ajax调用示例

    1.新建 a.html <!doctype html> <html> <head> <meta charset='utf-8'> <title&g ...

  6. C#操作XML的完整例子——XmlDocument篇

    这是一个用c#控制台程序下,  用XmlDocument 进行XML操作的的例子,包含了查询.增加.修改.删除.保存的基本操作.较完整的描述了一个XML的整个操作流程.适合刚入门.net XML操作的 ...

  7. HTML 转义符

    特殊字符 字符 十进制 转义字符 “ " " & & & < < < > > > 不断开空格(non-breaking ...

  8. jQuery 效果 - animate() 方法

    http://www.w3school.com.cn/jquery/effect_animate.asp 实例 改变 "div" 元素的高度: $(".btn1" ...

  9. asp.net 获取url

    string url = Request.Url.ToString(); this.ImageLogo.ImageUrl = "http://" + Request.Url.Aut ...

  10. 在Android上使用ZXing识别条形码/二维码

    越来越多的手机具备自动对焦的拍摄功能,这也意味着这些手机可以具备条码扫描的功能.......手机具备条码扫描的功能,可以优化购物流程,快速存储电子名片(二维码)等. 本文使用ZXing 1.6实现条码 ...