Problem

You're about to play a simplified "battleship" game with your little brother. The board for this game is a rectangular grid with R rows and C columns. At the start of the game, you will close your eyes, and you will keep them closed until the end of the game. Your little brother will take a single rectangular 1 x W ship and place it horizontally somewhere on the board. The ship must always fit entirely on the board, with each cell of the ship occupying exactly one of the grid's cells, and it can never be rotated.

In each turn of the game, you name a cell on the board, and your little brother tells you whether that is a hit (one of the cells occupied by the ship) or a miss. (Your little brother doesn't say which part of the ship was hit -- just that the cell you named has a part of the ship in it.) You have perfect memory, and can keep track of all the information he has given you. Once you have named all of the cells occupied by the ship, the game is over (the ship is sunk), and your score is the number of turns taken. Your goal is to minimize your score.

Although the ship is not supposed to be moved once it is placed, you know that your little brother, who is a brat, plans to cheat by changing the location of the ship whenever he wants, as long as the ship remains horizontal and completely on the board, and the new location is consistent with all the information he has given so far. For example, for a 1x4 board and 1x2 ship, your little brother could initially place the ship such that it overlaps the leftmost two columns. If your first guess was row 1, column 2, he could choose to secretly move the ship to the rightmost two columns, and tell you that (1, 2) was a miss. If your next guess after that was (1, 3), though, then he could not say that was also a miss and move the ship back to its original location, since that would be inconsistent with what he said about (1, 2) earlier.

Not only do you know that your little brother will cheat, he knows that you know. If you both play optimally (you to minimize your score, him to maximize it), what is the lowest score that you can guarantee you will achieve, regardless of what your little brother does?

A:

 有r*c的一个矩阵,现在有一个1*w的条状物放在矩阵内,另一个人开始猜位置,
比如猜一个x y,假如这一条恰好覆盖了x y,就要回答他YES,
但是另一个人可以作弊,即移动那一条东西,然后说no,只要一直跟前面说的不矛盾即可,
假如双方都表现的最优,问最少需要几次才能确定1*w那一条的所有位置。
移动的话是不能旋转的,只能平移,可以放到任意位置上 。

解题思路:

假设只有一行,

  c % w == 0 时,每一行按照w一段选择一次,在每一段的中间选择, 那么最坏情况可以在第c/w次说中,锁定在最后一段
  c % w != 0时,第c /w 次猜中一个后,你肯定往两边中的某个方向判断了,这里可以多让你猜错一次。
  多行的情况的话其实就是其他r-1行都没有船的情况,每行需要c / w次
 
//#pragma comment(linker, "/STACK:16777216") //for c++ Compiler
#include <stdio.h>
#include <iostream>
#include <fstream>
#include <cstring>
#include <cmath>
#include <stack>
#include <string>
#include <map>
#include <set>
#include <list>
#include <queue>
#include <vector>
#include <algorithm>
#define Max(a,b) (((a) > (b)) ? (a) : (b))
#define Min(a,b) (((a) < (b)) ? (a) : (b))
#define Abs(x) (((x) > 0) ? (x) : (-(x)))
#define MOD 1000000007
#define pi acos(-1.0) using namespace std; typedef long long ll ;
typedef unsigned long long ull ;
typedef unsigned int uint ;
typedef unsigned char uchar ; template<class T> inline void checkmin(T &a,T b){if(a>b) a=b;}
template<class T> inline void checkmax(T &a,T b){if(a<b) a=b;} const double eps = 1e- ;
const int N = ;
const int M = * ;
const ll P = 10000000097ll ;
const int MAXN = ; int main() {
ofstream fout ("A-large-practice.out");
ifstream fin ("A-large-practice.in");
int i, j, k, T;
int R, C, W; fin >> T;
while (T--) {
fin >> R >> C >> W;
int Ret = R * (C / W);
if (C % W == ) {
Ret += W - ;
} else {
Ret += W;
}
static int numCase = ;
fout << "Case #" << ++numCase << ": " << Ret << endl;
} return ;
}

Google Code Jam Round 1C 2015 Problem A. Brattleship的更多相关文章

  1. Google Code Jam Round 1A 2015 Problem B. Haircut 二分

    Problem You are waiting in a long line to get a haircut at a trendy barber shop. The shop has B barb ...

  2. Google Code Jam Round 1A 2015 解题报告

    题目链接:https://code.google.com/codejam/contest/4224486/ Problem A. Mushroom Monster 这题题意就是,有N个时间点,每个时间 ...

  3. Google Code Jam 2014 资格赛:Problem B. Cookie Clicker Alpha

    Introduction Cookie Clicker is a Javascript game by Orteil, where players click on a picture of a gi ...

  4. Google Code Jam 2014 资格赛:Problem D. Deceitful War

    This problem is the hardest problem to understand in this round. If you are new to Code Jam, you sho ...

  5. [刷题]Google Code Jam 2017 - Round1 C Problem A. Ample Syrup

    https://code.google.com/codejam/contest/3274486/dashboard Problem The kitchen at the Infinite House ...

  6. [Google Code Jam (Round 1A 2008) ] A. Minimum Scalar Product

    Problem A. Minimum Scalar Product   This contest is open for practice. You can try every problem as ...

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

  8. 【二分答案】Google Code Jam Round 1A 2018

    题意:有R个机器人,去买B件商品,有C个收银员,每个收银员有能处理的商品数量上限mi,处理单件商品所需的时间si,以及最后的装袋时间pi. 每个收银员最多只能对应一个机器人,每个机器人也最多只能对应一 ...

  9. 【贪心】Google Code Jam Round 1A 2018 Waffle Choppers

    题意:给你一个矩阵,有些点是黑的,让你横切h刀,纵切v刀,问你是否能让切出的所有子矩阵的黑点数量相等. 设黑点总数为sum,sum必须能整除(h+1),进而sum/(h+1)必须能整除(v+1). 先 ...

随机推荐

  1. Sublime Text2

    Ctrl+L选择整行(按住-继续选择下行) Ctrl+KK 从光标处删除至行尾 Ctrl+Shift+K 删除整行 Ctrl+Shift+D 复制光标所在整行,插入在该行之前 Ctrl+J 合并行(已 ...

  2. 射频识别技术漫谈(11)——Mifare系列卡的共性

    Mifare是NXP公司生产的一系列遵守ISO14443A标准的射频卡,包Mifare S50.Mifare S70.Mifare UltraLight.Mifare Pro.Mifare Desfi ...

  3. 用QComboBox实现tree状结构(QComboBox居然有setView和setModel函数)

    实现的效果图如下:  #include "mainwindow.h" #include <QApplication> #include <QTreeView> ...

  4. 手工部署Sqlserver CLR程序集

    原文 手工部署Sqlserver CLR程序集 以前一直用VS部署Sqlserver CLR程序集简单省事,现在服务器部署在内网了,必须手动更新部署Sqlserver CLR程序集.    开始以为A ...

  5. 用C#开发较完整的Windows任务管理器

    原文 用C#开发较完整的Windows任务管理器 这个代码没有什么技术含量,仅仅使用 WMI 和 API 实现了 Windows 任务管理器的部分功能. 但代码里面封装了一个 SystemInfo 的 ...

  6. Spring Boot 属性配置和使用

    Spring Boot 属性配置和使用 Spring Boot 允许通过外部配置让你在不同的环境使用同一应用程序的代码,简单说就是可以通过配置文件来注入属性或者修改默认的配置. Spring Boot ...

  7. ThinkPHP 3.1.2 查询方式的一般使用1

    public function show(){ echo "访问了index模块下的show方法!!"; echo "欢迎你".$_GET['name'].'你 ...

  8. JAVA 线程学习 - Thread了解

    public class ThreadKnow { private TimeThread timeThread; private boolean flag; public ThreadKnow() { ...

  9. #, about:blank,javascript:路径比较

    试了一下在<a>,<img>,<iframe>中用#,about:blank和javascript: 代码如下: <!Doctype html> < ...

  10. mac 上搭建SVN

    copy from 广东小码哥,M了个J. 在Windows环境中,我们一般使用TortoiseSVN来搭建svn环境.在Mac环境下,由于Mac自带了svn的服务器端和客户端功能,所以我们可以在不装 ...