Codeforces Bubble Cup 8 - Finals [Online Mirror] D. Tablecity 数学题
D. Tablecity
Time Limit: 1 Sec
Memory Limit: 256 MB
题目连接
http://codeforces.com/contest/575/problem/D
Description
There was a big bank robbery in Tablecity. In order to catch the thief, the President called none other than Albert – Tablecity’s Chief of Police. Albert does not know where the thief is located, but he does know how he moves.
Tablecity can be represented as 1000 × 2 grid, where every cell represents one district. Each district has its own unique name “(X, Y)”, where X and Y are the coordinates of the district in the grid. The thief’s movement is as
Every hour the thief will leave the district (X, Y) he is currently hiding in, and move to one of the districts: (X - 1, Y), (X + 1, Y),(X - 1, Y - 1), (X - 1, Y + 1), (X + 1, Y - 1), (X + 1, Y + 1) as long as it exists in Tablecity.
Below is an example of thief’s possible movements if he is located in district (7,1):
Albert has enough people so that every hour he can pick any two districts in Tablecity and fully investigate them, making sure that if the thief is located in one of them, he will get caught. Albert promised the President that the thief will be caught in no more than 2015 hours and needs your help in order to achieve that.
Input
There is no input for this problem.
Output
The first line of output contains integer N – duration of police search in hours. Each of the following N lines contains exactly 4 integersXi1, Yi1, Xi2, Yi2 separated by spaces, that represent 2 districts (Xi1, Yi1), (Xi2, Yi2) which got investigated during i-th hour. Output is given in chronological order (i-th line contains districts investigated during i-th hour) and should guarantee that the thief is caught in no more than 2015 hours, regardless of thief’s initial position and movement.
- N ≤ 2015
- 1 ≤ X ≤ 1000
- 1 ≤ Y ≤ 2
Sample Input
Sample Output
HINT
题意
有一个1000*2的空间,里面有一个小偷,每次小偷可以往四周走一格,你并不知道小偷在哪儿
现在要求让你安排一种巡查方案,每次巡查两个房间,要求不管小偷采取什么方案,你都能抓住他
题解:
往左扫一遍,然后再往右扫一遍
很经典的一个面试题,大概就是奇偶性的关系吧,保证自己和老鼠会是同奇偶
代码:
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
printf("%d\n",);
for(int i=;i<=;i++)
printf("%d %d %d %d\n",i,,i,);
for(int i=;i>=;i--)
printf("%d %d %d %d\n",i,,i,);
return ;
}
Codeforces Bubble Cup 8 - Finals [Online Mirror] D. Tablecity 数学题的更多相关文章
- Codeforces Bubble Cup 8 - Finals [Online Mirror] B. Bribes lca
题目链接: http://codeforces.com/contest/575/problem/B 题解: 把链u,v拆成u,lca(u,v)和v,lca(u,v)(v,lca(u,v)是倒过来的). ...
- Codeforces Bubble Cup 8 - Finals [Online Mirror]H. Bots 数学
H. Bots Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/575/problem/H Desc ...
- Codeforces Bubble Cup 8 - Finals [Online Mirror] F. Bulbo DP
F. Bulbo Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/575/problem/F Des ...
- Bubble Cup 12 - Finals Online Mirror, unrated, Div. 1
Bubble Cup 12 - Finals Online Mirror, unrated, Div. 1 C. Jumping Transformers 我会状压 DP! 用 \(dp[x][y][ ...
- Bubble Cup 11 - Finals [Online Mirror, Div. 1]题解 【待补】
Bubble Cup 11 - Finals [Online Mirror, Div. 1] 一场很好玩的题啊! I. Palindrome Pairs 枚举哪种字符出现奇数次. G. AI robo ...
- 【简单dfs】Bubble Cup 14 - Finals Online Mirror (Unrated, ICPC Rules, Teams Preferred, Div. 2), problem: (J) Robot Factory,
传送门 Problem - 1600J - Codeforces 题目 题意 给定n行m列, 求每个连通块由多少格子组成,并将格子数从大到小排序输出 对于每个格子都有一个数(0~15),将其转化 ...
- Bubble Cup X - Finals [Online Mirror]
来自FallDream的博客,未经允许,请勿转载,谢谢. 组了个菜鸡队打cf上的ACM比赛 比较快做完了8题但是菜的抠脚罚时巨多,所以最后被顶到了19名(居然没出首页) 自己的号自从上次疯狂掉分就没动 ...
- Bubble Cup X - Finals [Online Mirror] B. Neural Network country 矩阵快速幂加速转移
B. Neural Network country time limit per test 2 seconds memory limit per test 256 megabytes Due to t ...
- Bubble Cup 12 - Finals [Online Mirror, unrated, Div. 1] E. Product Tuples
题意略,题解生成函数练习题,1+(q-ai)x卷积即可,线段树优化(类似分治思想) //#pragma GCC optimize(2) //#pragma GCC optimize(3) //#pra ...
随机推荐
- Linux应用层直接操作GPIO
Linux应用层直接操作GPIO 在一个老手的指导下,应用层可以直接操作GPIO,具体指设置GPIO的输入输出以及输出电平高或者低.这个大大地提高了灵活性,官方的文档有GPIO Sysfs Inter ...
- POJ 1195- Mobile phones(二维BIT)
题意: 矩阵上的单点更新,范围求和 #include <map> #include <set> #include <list> #include <cmath ...
- 浅谈javascript的变量作用域
1.变量遵循先声明再使用. console.log(b); b=123; 代码运行结果: Uncaught ReferenceError: b is not defined 2.方法内定义的局部变量外 ...
- RockMongo安装使用笔记
下载nginx最新版本下载PHP,5.X版本即可,非线程安全的的,因为nginx用的是fastcgi下载rockmongo最新版本下载php_mongo组件 在rockmongo里的readme里有下 ...
- 获取本机外网IP的方式笔记
1.IP138 网址:http://www.ip138.com/: 分离出的快速查询地址:http://20140507.ip138.com/ic.asp(2014年8月9日有效) 个人经验:百度搜索 ...
- PowerDesigner Vs Enterprise Architect
注: 以下文中PD表示PowerDesigner,EA表示Enterprise Architect 最近一直在做设计方面的事情,之前一直在用PD.有个阿里过来的同事说阿里都是用EA,我就抽空小研究了一 ...
- 取消eclipse启动时的subclipse Usage弹窗
取消windows–>perferences–>general–>startup and shutdown里最下面的Subclipse Usage report 勾选即可
- convert source code files to pdf format in python
import os import sys def find_file(root_dir, type): dirs_pool = [root_dir] dest_pool = [] def scan_d ...
- ASP.NET MVC3 系列教程 - Razor视图引擎基础语法
http://www.cnblogs.com/highend/archive/2011/04/09/aspnet_mvc3_razor_engine.html 4. 关于所有带"_" ...
- [Hive-Tutorial] What Is Hive
What Is Hive Hive is a data warehousing infrastructure based on Hadoop. Hadoop provides massive scal ...