21806_CatJi

2022-5-16 18:20| 发布者: Hocassian| 查看: 22| 评论: 0|原作者: 肇庆学院ACM合集

摘要:
C:\Users\Administrator\Downloads\2019-10-12-10-14-4-89505864408900-Problem List-采集的数据-后羿采集器.html

Pro.ID

21806

Title

Cat Jim

Title链接

http://10.20.2.8/oj/exercise/problem?problem_id=21806

AC

0

Submit

0

Ratio

-

时间&空间限制

  • Time Limit: 2000/1000 MS (Java/Others)     Memory Limit: 65536/65536 K (Java/Others)
  • 描述

    Long long ago, there was a very big forest, called Happy Forest. In the forest, there was a very naughty cat, named Jim. One day, when Jim played in the forest, he was attracted by a beautiful butterfly and followed the butterfly, he went into the dire area, the Black Forest

    An evil wizard lived in the Black Forest, he would kill anyone who entered the forest, and had a good meal with their bodies. Obviously, Jim knew what would happen to him. As a clever cat, Jim came up an idea quickly, that is, calling for help.

    Unfortunately, the wizard trapped Jim with a magic called Maze, and then he went home prepered for the delicious cat-meet-dinner. He would come back at time T.

    The magic Maze transmits somebody to a special square. At there, one must solve a riddle to get out, or waiting for powerful wizard to dispel the Maze.

    On the square, there are N rows stone. Each row has M stones. Each stone has its own number, and there are M pieces of stone whose number is k ( 1 ≤ kN ). Only all the stone in k-th row has the same number k, the person can exit the Maze.

    Certainly, Jim didn't want to become a cat-meet-dinner, so he asked you for help.

    You can assume Jim would take 1 time from one row to any row (nomatter he took a stone or not), and when start (time 0), he could go to any row he likes.

    Notice: even Jim can get out of magic Maze, he also need at least 1 time to call for help. (After that he would save by SuperCat and Wizard would lost his cat-meet-dinner. Clearly he might be crazy and do something terrible. For exmaple, he might summon some vampire to catch the cat Jim and then destroy the Happy Forest:( After all, he was a dread wizard.)

    输入

    The first line contains N ( the number of row, 1 ≤ N ≤ 10000 ), M (the number of stone in each row, 1 ≤ M ≤ 100 ), T ( the time mentioned before, T ≤ 232 ), Each of the next N lines contains M numbers in the range from 1 to N. The numbers are separated with a space.

    输出

    Description

    Long long ago, there was a very big forest, called Happy Forest. In the forest, there was a very naughty cat, named Jim. One day, when Jim played in the forest, he was attracted by a beautiful butterfly and followed the butterfly, he went into the dire area, the Black Forest

    An evil wizard lived in the Black Forest, he would kill anyone who entered the forest, and had a good meal with their bodies. Obviously, Jim knew what would happen to him. As a clever cat, Jim came up an idea quickly, that is, calling for help.

    Unfortunately, the wizard trapped Jim with a magic called Maze, and then he went home prepered for the delicious cat-meet-dinner. He would come back at time T.

    The magic Maze transmits somebody to a special square. At there, one must solve a riddle to get out, or waiting for powerful wizard to dispel the Maze.

    On the square, there are N rows stone. Each row has M stones. Each stone has its own number, and there are M pieces of stone whose number is k ( 1 ≤ kN ). Only all the stone in k-th row has the same number k, the person can exit the Maze.

    Certainly, Jim didn't want to become a cat-meet-dinner, so he asked you for help.

    You can assume Jim would take 1 time from one row to any row (nomatter he took a stone or not), and when start (time 0), he could go to any row he likes.

    Notice: even Jim can get out of magic Maze, he also need at least 1 time to call for help. (After that he would save by SuperCat and Wizard would lost his cat-meet-dinner. Clearly he might be crazy and do something terrible. For exmaple, he might summon some vampire to catch the cat Jim and then destroy the Happy Forest:( After all, he was a dread wizard.)

    Input

    The first line contains N ( the number of row, 1 ≤ N ≤ 10000 ), M (the number of stone in each row, 1 ≤ M ≤ 100 ), T ( the time mentioned before, T ≤ 232 ), Each of the next N lines contains M numbers in the range from 1 to N. The numbers are separated with a space.

    Output

    The first line is minimal possible time he needed to get out of magic Maze. If he would become a cat-meet-dinner, you must put another line, "Poor Cat".

    Sample Input

    4 3 10
    1 3 1
    2 3 3
    1 2 2
    4 4 4
    4 3 1
    1 3 1
    2 3 3
    1 2 2
    4 4 4

    Sample Output

    6
    6
    Poor Cat

    Source

    样例输入

    4 3 10
    1 3 1
    2 3 3
    1 2 2
    4 4 4
    4 3 1
    1 3 1
    2 3 3
    1 2 2
    4 4 4

    样例输出

    6
    6
    Poor Cat

    作者


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部