(线段树 + 离散化 ) hdu 3627 Giant For

Giant For

Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 1397    Accepted Submission(s): 261

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

Source
ps:当时没学线段树,一看数据这么大就蒙了,现在学了线段树就做了起来。效率还不错1548ms AC
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值