zoukankan      html  css  js  c++  java
  • Codeforces Bubble Cup 8

    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
    ",2000);
        for(int i=1;i<=1000;i++)
            printf("%d %d %d %d
    ",i,1,i,2);
        for(int i=1000;i>=1;i--)
            printf("%d %d %d %d
    ",i,1,i,2);
        return 0;
    }
  • 相关阅读:
    课后作业2
    软工团队项目度量反馈平台需求分析文档-北航软工暑期培训班团队项目1组
    《构建之法》教学笔记——Python中的效能分析与几个问题
    高职院校软件技术专业程序设计课程体系探索(一)
    network_node:host解决Docker容器化部署微服务出现的Dobbo通信问题
    微服务中的健康监测以及其在ASP.NET Core服务中实现运行状况检查
    词频统计
    消息队列
    Linux文件扩展思考随笔
    如何在Mirth Connect中创建和调用自定义Java代码
  • 原文地址:https://www.cnblogs.com/qscqesze/p/4787621.html
Copyright © 2011-2022 走看看