MON2012 - Monkey and apples
Monkey Chris loves apples. That's why he has planted lots of apple trees. He does two types of operations on this trees.
- First operation "1 x y": means counting ripe apple trees on interval [x+c, y+c].
- Second operation "2 x y": means that all apples on interval [x+c, y+c] get ripe(edible).
C=0 in the beginning and becomes the answer of each query ("1" operation).
Input
Input begins with M (1 <= M <= 10^5) the number of operations. Afterwards M lines each of them is an operation ("1" or "2"). 1<=X+C; Y+C<=10^9.
Example
Input 3 2 5 8 2 7 10 1 1 10 Output 6
Explanation
3 queries. Apples gets ripe on intervals 5-8 and 7-10. There are totally 6 ripe apple-trees on interval 1-10 so answer to query is 6.
hide comments
DK...:
2019-04-28 13:22:15
I got several TL's, It's necesary improve ur code for AC |
|
:(:
2015-01-23 16:16:59
@$iddharth prasad the problem statement is simple u will be given a range update and a ragne query :D
|
|
rohith:
2015-01-20 13:39:40
donot think too much a simple dynamic modification of segment tree :D |
|
$iddharth prasad:
2013-08-30 18:27:06
someone plzz clarify the question
|
|
:D:
2012-04-05 15:25:46
Thanks for respond.
|
|
:D:
2012-04-05 15:25:46
It would be great if data check could be done here. It's hard to say here, because WA's can lead to this results, but I brute checked A LOT and extended the allowable data limits. There could be some issues with the file encoding or data itself on the 20-21 test case.
|
|
[Rampage] Blue.Mary:
2012-04-05 15:25:46
I can't understand how my program caused RE(SIG). I've used assert and found (at least in my program) there's some test case(s) in which the given x<0, i.e. it doesn't meet the problem statement.
|
|
Devil D:
2012-04-05 15:25:46
what is the value of c in 'x+c' and 'y+c'
|
Added by: | Ikhaduri |
Date: | 2012-02-11 |
Time limit: | 0.107s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: ADA95 ASM32 ASM64 GAWK BASH BF C99 CLPS CLOJURE LISP sbcl LISP clisp D ERL FSHARP FORTRAN GO ICON ICK JS-RHINO LUA NEM NICE OCAML PAS-GPC PERL PERL6 PHP PIKE PRLG-swi SCALA SCM guile SCM qobi SED ST TCL |
Resource: | izho 2012 |