Google Code Jam Round 1C 2015 Problem A. Brattleship
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那一条的所有位置。
移动的话是不能旋转的,只能平移,可以放到任意位置上 。
解题思路:
假设只有一行,
//#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的更多相关文章
- 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 ...
- Google Code Jam Round 1A 2015 解题报告
题目链接:https://code.google.com/codejam/contest/4224486/ Problem A. Mushroom Monster 这题题意就是,有N个时间点,每个时间 ...
- 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 ...
- 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 ...
- [刷题]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 ...
- [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 ...
- 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 ...
- 【二分答案】Google Code Jam Round 1A 2018
题意:有R个机器人,去买B件商品,有C个收银员,每个收银员有能处理的商品数量上限mi,处理单件商品所需的时间si,以及最后的装袋时间pi. 每个收银员最多只能对应一个机器人,每个机器人也最多只能对应一 ...
- 【贪心】Google Code Jam Round 1A 2018 Waffle Choppers
题意:给你一个矩阵,有些点是黑的,让你横切h刀,纵切v刀,问你是否能让切出的所有子矩阵的黑点数量相等. 设黑点总数为sum,sum必须能整除(h+1),进而sum/(h+1)必须能整除(v+1). 先 ...
随机推荐
- 循环-10. 求序列前N项和(15)
#include<iostream>#include<iomanip>using namespace std;int main(){ double i,n,t,a,b; ...
- Linux下使用ps命令来查看Oracle相关的进程
Linux下可以使用ps命令来查看Oracle相关的进程 Oracle Listener 这个命令会列出Oracle Net Listener的进程 [oracle@ www.linuxidc.com ...
- Loggerly技术架构
https://www.loggly.com/blog/topic/log-management-technology/
- 【双模卡的相关知识】解SIM卡前需要知道的信息(SIM年分和厂商识别)
<ignore_js_op> 二.SIM版本问题SIM卡的版本有两种说法,一是有些是制造厂制定的,二是电信公司的制定.下面以移动为例,目前我们手里的SIM有几种版本:v0.v1.v2.v3 ...
- Google日历添加农历、节日和天气插件(步骤)
Google日历添加农历.节日和天气插件(步骤) Google功能非常多,Google日历只是其中一个,而且支持Exchange账户(iPhone,WP7,诺基亚等)和Google账户登录(andro ...
- Java中String、StringBuilder以及StringBuffer
原文出处: 海子 相信String这个类是Java中使用得最频繁的类之一,并且又是各大公司面试喜欢问到的地方,今天就来和大家一起学习一下String.StringBuilder和StringBuffe ...
- DRP过后,感受知识间的通性
DRP视频看了不短的时间,真正开始DRP的时间是7月17号,至今两个月了.由于暑假期间英语的学习占得时间比较多,所以DRP视频进行的很慢.9月11号看完了DRP所有的视频,这个项目完成后最大的感受是: ...
- 查找jar包的站点
1.findJAR.com: http://www.findjar.com/index.x 2.jarfire: https://cn.jarfire.org/
- delphi webbrowser 经常用法演示样例
var Form : IHTMLFormElement ; D:IHTMLDocument2 ; begin with WebBrowser1 do begin D := Document as IH ...
- 怎样在SharePoint管理中心检查数据库架构版本号、修补级别和修补程序的常规监控
怎样在SharePoint管理中心检查数据库架构版本号.修补级别和修补程序的常规监控 准备: 确保你是可以訪问管理中心的场管理员. 開始: 1. 打开管理中心--升级和迁移. 2. 点击"查 ...