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. How Tomcat Works(十二)

    tomcat容器通过一个称为Session管理器的组件来管理建立的Session对象,该组件由org.apache.catalina.Manager接口表示:Session管理器必须与一个Contex ...

  2. “非常PHP学习网”(www.veryphp.cn)一期上线

    制作“非常PHP学习网”花了国庆整个假期,其实是从电脑学习网(http://www.why100000.com,域名刚续费)改写盗版而来的. 起初主要修改界面布局和颜色花费了大量时间(好像制作网站80 ...

  3. 基数排序详解以及java实现

    前言 基数排序(radix sort)又称桶排序(bucket sort),相对于常见的比较排序,基数排序是一种分配式排序,即通过将所有数字分配到应在的位置最后再覆盖到原数组完成排序的过程.我在上一篇 ...

  4. 【转】google推出的SwipeRefreshLayout下拉刷新用法

    SwipeRefreshLayout是Google在support v4 19.1版本的library更新的一个下拉刷新组件,实现刷新效果更方便. 使用如下: 1.先下载android-support ...

  5. 使用Office-Word的博客发布功能(测试博文)

    本人打算在博客园开博,但平时收集和整理资料都在OneNote中,又不想在写博客时还要进行复制粘贴操作,于是就想到了Microsoft Office自带的博客发布功能.在此做了一下测试,发布了此博文. ...

  6. 定制个性化的FlashPaper生成的文件

    1:找到已安装FlashPaper目录下的子目录Interface下的文件DefaultViewer2.swf,在此swf文件的基础上实现自己的修改. 2:利用swf反编译工具,这里推荐 硕思闪客精灵 ...

  7. 全代码实现ios-4

    刚开始开发的时候,也曾经想用IB或Storyboard. 不过看了许多篇关于IB和Storyboard的操作文档后仍然是糊里糊涂,不由得怀疑自己的IQ. 可不可以全代码实现ios开发?当时我想. 不过 ...

  8. Hadoop on Mac with IntelliJ IDEA - 5 解决java heap space问题

    本文讲述在CentOS 6.5中提交作业到hadoop 1.2.1于reduce阶段遇到Error: java heap space错误导致作业重新计算的解决过程.解决办法适用Linux.Mac OS ...

  9. Overview and tips for using STM32F303

    www.stmcu.org/download/index.php?act=down&id=5264 IntroductionThe purpose of this application no ...

  10. Codeforces Gym 100187E E. Two Labyrinths bfs

    E. Two Labyrinths Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100187/prob ...