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. sql waitfor 延时执行

    看MSDN:http://msdn.microsoft.com/zh-cn/library/ms187331.aspx 语法为: WAITFOR { DELAY 'time_to_pass' | TI ...

  2. WebService《JavaEE6权威指南 基础篇第4版》

    [Web服务] 为运行在不同平台和框架之上的软件提供了互操作的标准方式.良好的互操作性和可扩展性.消息采用自包含文档的形式. ——解决异构系统之间交互.解决异构系统通信问题:  1.通过XML,JSO ...

  3. 配置Redis主从复制

    [构建高性能数据库缓存之redis主从复制][http://database.51cto.com/art/201407/444555.htm] 一.什么是redis主从复制? 主从复制,当用户往Mas ...

  4. 事件委托&jQuery on

    例如: <h2>Great Web resources</h2> <ul id="resources"> <li><a hre ...

  5. cocos2d-x (Android)之-那些常见的error记

    转自:http://blog.csdn.net/callchunli/article/details/8929813 (2013/9/2) build.xml:939: java.lang.Array ...

  6. ARM architectures

    https://gitorious.org/freebsd/freebsd/raw/56c5165837bf08f50ca4a08c6b2da91f73852960:sys/arm/include/a ...

  7. Eclipse配置PyDev插件

    安装python解释器 安装PyDev: 首先需要去Eclipse官网下载:http://www.eclipse.org/,Eclipse需要JDK支持,如果Eclipse无法正常运行,请到Java官 ...

  8. 第七届ACM趣味程序设计竞赛第四场(正式赛) 题解

    Final Pan's prime numbers 题目连接: http://acm.uestc.edu.cn/#/problem/show/1272 题意 给你n,要求你在[4,n]范围内找到一个最 ...

  9. JS的加载方式---同步和异步

    同步加载及异步加载,只有这两种方式. 动态加载是异步加载的方式之一. ajax加载也是异步加载.

  10. [AngularJS] TweenList 3D + AngularJS Animate

    AngularJS animations and TweenLite make it really easy to create cool 3d effects in your application ...