22852_Ivancomesagain!

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

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

Pro.ID

22852

Title

Ivan comes again!

Title链接

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

AC

1

Submit

1

Ratio

100.00%

时间&空间限制

  • Time Limit: 6000/3000 MS (Java/Others)     Memory Limit: 65536/65536 K (Java/Others)
  • 描述

    The Fairy Ivan gave Saya three problems to solve (Problem 22849). After Saya finished the first problem (Problem 22851), here comes the second.

    This is the enhanced version of Problem 22849.

    There is a large matrix whose row and column are less than or equalto 1000000000. And there are three operations for the matrix:

    1) add: Mark an element in the matrix. The element wasn't marked before it is marked.

    2) remove: Delete an element's mark. The element was marked before the element's mark is deleted.

    3) find: Show an element's row and column, and return a marked element's row and column, where the marked element's 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 there is no solution, return -1.

    Of course, Saya comes to you for help again.

    输入

    The input consists of several test cases.

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

    Each of the next N lines containing an operation, as described above.

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

    输出

    Description

    The Fairy Ivan gave Saya three problems to solve (Problem 22849). After Saya finished the first problem (Problem 22851), here comes the second.

    This is the enhanced version of Problem 22849.

    There is a large matrix whose row and column are less than or equalto 1000000000. And there are three operations for the matrix:

    1) add: Mark an element in the matrix. The element wasn't marked before it is marked.

    2) remove: Delete an element's mark. The element was marked before the element's mark is deleted.

    3) find: Show an element's row and column, and return a marked element's row and column, where the marked element's 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 there is no solution, return -1.

    Of course, Saya comes to you for help again.

    Input

    The input consists of several test cases.

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

    Each of the next N lines containing an operation, as described above.

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

    Output

    For each case, print the case number (1, 2 …) first. Then, for each "find" operation, output the result. Your output format should imitate the sample output. Print a blank line after each test case.

    Sample Input

    4
    add 2 3
    find 1 2
    remove 2 3
    find 1 2

    0

    Sample Output

    Case 1:
    2 3
    -1

    Source

    样例输入

    4
    add 2 3
    find 1 2
    remove 2 3
    find 1 2

    0

    样例输出

    Case 1:
    2 3
    -1

    作者


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部