P3422 [POI2005]LOT-A Journey to Mars

    • 126通过
    • 412提交
  • 题目提供者 洛谷
  • 评测方式 云端评测
  • 标签 并查集 枚举,暴力 深度优先搜索,DFS POI 2005 高性能
  • 难度 提高+/省选-
  • 时空限制 1000ms / 128MB

题解

  • 提示:收藏到任务计划后,可在首页查看。
  • 体验新版界面

    最新讨论 显示

    推荐的相关题目 显示

    题目描述

    Byteazar has decided on going to Mars to tour the space stations there being in existence. All marsian space stations lie on a circumference of a circle. Byteazar lands in one of them and then moves around by means of a special vehicle which is powered by an appropriate fuel. A litre of this fuel allows him to travel one meter. However, the provisions of the fuel are meagre, different quantities of it are available in each space station. Byteazar may refuel in the space station he is currently in, though he cannot get more fuel than it is available in that very place (the capacity of his fuel tank is unlimited). This quantity of fuel should allow him to reach the next space station. Byteazar has to decide where to land, so that he can visit all of the space stations. In the end he has to return to the space station in which he has landed. During his journey Byteazar has to travel on the circumference of the circle, constantly in one of the two possible directions.

    TaskWrite a programme which:

    reads from the standard input the number of space stations, distances between them and the amount of fuel available in each of them,for each of the space stations checks, whether Byteazar can land there i.e. whether by starting in that very station and travelling in a freely chosen direction he is able to visit all of the space stations and return to his spaceship,writes the outcome to the standard output.

    Byteazar 决定去火星参加一个空间站旅行. 火星的所有空间站都位于一个圆上. Byteazar 在其中一个登陆然后变开始饶圈旅行. 旅行需要耗费油料,一升油料只能跑1米,每个空间站可以补给的油料都有所不同. Byteazar 每到一个空间站便可以把该空间站的油料全部拿走.(他的油箱是没有容量限制的) 但是如果走到某个时候突然没油了那么旅行便失败了. Byteazar 需要决定要在哪个地方登陆使得他能顺利访问完所有的空间站后回到他当初登陆的地方. 一个细节是他登陆后可以选择两个方向中的任意一个进行旅行.

    输入输出格式

    输入格式:

    The first line of the standard input contains a single integer $N$ ($3\le N\le 1\ 000\ 000$). It denotes the number of space stations on Mars. The space stations are numbered from $1$ to $N$. In the next $N$ lines there is a description of all of the stations and the distances between them. The $(i+1)$'st line contains two integers $p_i$ and $d_i$ ($p_i\le 0, d_i>0$). The first one denotes the amount of fuel (in litres) available in the $i$'th space station. The other denotes the distance (in metres) between the $i$'th and $(i+1)$'st space station (obviously $d_N$ denotes the distance between the $N$'th and the $1$st space station) .The total amount of available fuel, as well as the sum of all distances between the space stations does not exceed $2\ 000\ 000\ 000$.

    输出格式:

    The programme should write $N$ lines to the standard output. The $i$'th line should contain the word TAK (i.e. yes is Polish), if Byteazar can land in the $i$'th space station or NIE (i.e. no in Polish) when it is not possible.

    输入输出样例

    输入样例#1: 复制
    5
    3 1
    1 2
    5 2
    0 1
    5 4
    输出样例#1: 复制
    TAK
    NIE
    TAK
    NIE
    TAK
    提示
    标程仅供做题后或实在无思路时参考。
    请自觉、自律地使用该功能并请对自己的学习负责。
    如果发现恶意抄袭标程,将按照I类违反进行处理。