22851_HelloWorld!

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

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

Pro.ID

22851

Title

Hello World!

Title链接

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

AC

1

Submit

4

Ratio

25.00%

时间&空间限制

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

    We know that Ivan gives Saya three problems to solve (Problem 22849), and this is the first problem.

    "We need a programmer to help us for some projects. If you show us that you or one of your friends is able to program, you can pass the first hurdle.

    I will give you a problem to solve. Since this is the first hurdle, it is very simple."

    We all know that the simplest program is the "Hello World!" program. This is a problem just as simple as the "Hello World!"

    In a large matrix, there are some elements has been marked. For every marked element, return a marked element whose row and column are larger than the showed element's row and column respectively. If there are multiple solutions, return the element whose row is the smallest; and if there are still multiple solutions, return the element whose column is the smallest. If thereis no solution, return -1 -1.

    Saya is not a programmer, so she comes to you for help.

    Can you solve this problem for her?

    输入

    The input consists of several test cases.

    The first line of input in each test case contains one integer N ( 0 < N ≤ 1000 ), which represents the number of marked element.

    Each of the next N lines containing two integers r and c, represent the element's row and column. You can assume that 0 < r, c ≤ 300. A marked element can be repeatedly showed.

    The last case is followed by a line containing one zero.

    输出

    Description

    We know that Ivan gives Saya three problems to solve (Problem 22849), and this is the first problem.

    "We need a programmer to help us for some projects. If you show us that you or one of your friends is able to program, you can pass the first hurdle.

    I will give you a problem to solve. Since this is the first hurdle, it is very simple."

    We all know that the simplest program is the "Hello World!" program. This is a problem just as simple as the "Hello World!"

    In a large matrix, there are some elements has been marked. For every marked element, return a marked element whose row and column are larger than the showed element's row and column respectively. If there are multiple solutions, return the element whose row is the smallest; and if there are still multiple solutions, return the element whose column is the smallest. If thereis no solution, return -1 -1.

    Saya is not a programmer, so she comes to you for help.

    Can you solve this problem for her?

    Input

    The input consists of several test cases.

    The first line of input in each test case contains one integer N ( 0 < N ≤ 1000 ), which represents the number of marked element.

    Each of the next N lines containing two integers r and c, represent the element's row and column. You can assume that 0 < r, c ≤ 300. A marked element can be repeatedly showed.

    The last case is followed by a line containing one zero.

    Output

    For each case, print the case number (1, 2 …), and for each element's row and column, output the result. Your output format should imitate the sample output. Print a blank line after each test case.

    Sample Input

    3
    1 2
    2 3
    2 3

    0

    Sample Output

    Case 1:
    2 3
    -1 -1
    -1 -1

    Source

    样例输入

    3
    1 2
    2 3
    2 3

    0

    样例输出

    Case 1:
    2 3
    -1 -1
    -1 -1

    作者


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部