编程介的小学生 2019-03-27 21:42 采纳率: 20.5%
浏览 285

数列数组的增加删除修改寻找的一个问题,采用C语言的程序设计的方式怎么实现代码的编写

Problem Description
It is known to us all that YY and LMY are mathematics lovers. They like to find and solve interesting mathematic problems together. Now LMY designs a game for matrix. There is a large matrix whose rows and columns are both not more than 1000000000. And there are three operations for the matrix:
1) add: Mark an element in the matrix. It is guaranteed that the element has not been marked before.
2) remove: Delete an element’s mark. It is guaranteed that the element has been marked before.
3) find: For a given element’s row and column, return a marked element’s row and column, where the marked element’s row and column are larger than the given 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.
LMY lets YY develop a program to solve the problem. Could you also develop a program to solve the problem?

Input
The input consists of multiple test cases. For each test case, the first line contains only one integer n. n ≤ 200000. Each of the next n lines describes an operation. There is a blank line between two consecutive test cases.
End of input is indicated by a line containing a zero.

Output
Start each test case with "Case #:" on a single line, where # is the case number starting from 1. For each “find” operation, output the result. The format is showed as sample output. There is a blank line between two consecutive test cases.

Sample Input
5
add 48 1
add 25 69
add 88 52
remove 25 69
add 23 89

10
add 47 23
find 66 83
find 27 73
add 84 97
find 10 58
remove 47 23
add 41 89
remove 41 89
find 65 68
add 25 41

0

Sample Output
Case 1:

Case 2:
-1
-1
84 97
84 97

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 乘性高斯噪声在深度学习网络中的应用
    • ¥15 运筹学排序问题中的在线排序
    • ¥15 关于docker部署flink集成hadoop的yarn,请教个问题 flink启动yarn-session.sh连不上hadoop,这个整了好几天一直不行,求帮忙看一下怎么解决
    • ¥30 求一段fortran代码用IVF编译运行的结果
    • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
    • ¥15 C++ 头文件/宏冲突问题解决
    • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
    • ¥50 安卓adb backup备份子用户应用数据失败
    • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
    • ¥30 python代码,帮调试,帮帮忙吧