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. CCD摄像机与CMOS摄像机区别

    CCD摄像机 什么是CCD摄像机? CCD是Charge Coupled Device(电荷耦合器件)的缩写,它是一种半导体成像器件,因而具有灵敏度高.抗强光.畸变小.体积小.寿命长.抗震动等优点. ...

  2. jpa动态创建EntityManagerFactory 态设置数据库连接 EntityManager;

    //jpa动态创建EntityManagerFactory 态设置数据库连接EntityManager;createEntityManagerFactory(String persistenceUni ...

  3. [LeetCode] Consecutive Numbers 连续的数字 --数据库知识(mysql)

    1. 题目名称   Consecutive Numbers 2 .题目地址 https://leetcode.com/problems/consecutive-numbers/ 3. 题目内容 写一个 ...

  4. 最小生成树之Prime法

    关于最小生成树的概念,在前一篇文章中已经讲到,就不在赘述了.下面介绍Prime算法:         其基本思想为:从一个顶点出发,选择由该顶点出发的最小权值边,并将该边的另一个顶点包含进来,然后找出 ...

  5. UI:MVC设计模式

    不是因为有些事情难以做到,我们才失去自信:而是因为我们失去了自信,有些事情才显得难以做到.自信的第一步就是去尝试.不是因为有希望才坚持,而是因为坚持才有了希望.坚持尝试,就有可能成功.加油! Xcod ...

  6. Http下的各种操作类.WebApi系列~通过HttpClient来调用Web Api接口

    1.WebApi系列~通过HttpClient来调用Web Api接口 http://www.cnblogs.com/lori/p/4045413.html HttpClient使用详解(java版本 ...

  7. Spring aop expression

    任意公共方法的执行:execution(public * *(..))任何一个名字以“set”开始的方法的执行:execution(* set*(..))AccountService接口定义的任意方法 ...

  8. UIWebView 获取当前的javascript上下文,并js,oc互调

    OC调用UIWebView 中的js,网上例子很多,最常用的是UIWebView自带的一个方法: - (NSString *)stringByEvaluatingJavaScriptFromStrin ...

  9. sc7731 Android 5.1 Camera 学习之二 framework 到 HAL接口整理

    前面已经分析过,Client端发起远程调用,而实际完成处理任务的,是Server端的 CameraClient 实例.远程client 和 server是两个不同的进程,它们使用binder作为通信工 ...

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