GravelProblem code: SPREAD |
All submissions for this problem are available.
Bob has n heap(s) of gravel (initially there are exactly c piece(s) in each). He wants to do m operation(s) with that heaps, each maybe:
- adding pieces of gravel onto the heaps from u to v, exactly k pieces for each,
- or querying "how many pieces of gravel are there in the heap p now?".
Request
Help Bob do operations of the second type.
Input
- The first line contains the integers n,m,c, respectively.
- m following lines, each forms:
- S u v k to describe an operation of the first type.
- Q p to describe an operation of the second type.
(Each integer on a same line, or between the characters S, Q and the integers is separated by at least one space character)
Output
For each operation of the second type, output (on a single line) an integer answering to the respective query (follows the respective Input order).
Example
Input:7 5 0 Q 7 S 1 7 1 Q 3 S 1 3 1 Q 3Output:
0 1 2
Limitations
- 0<n≤106
- 0<m≤250 000
- 0<u≤v≤n
- 0≤c,k≤109
- 0<p≤n
| Author: | anhdq |
| Tester: | rajivka |
| Editorial | http://discuss.codechef.com/problems/SPREAD |
| Date Added: | 5-05-2010 |
| Time Limit: | 2 sec |
| Source Limit: | 50000 Bytes |
| Languages: | ADA, ASM, BASH, C, C99 strict, CLOJ, CPP 4.0.0-8, CPP 4.3.2, CS2, D, FORT, FS, GO, ICON, JAR, JAVA, LISP clisp, LISP sbcl, LUA, NEM, NICE, NODEJS, PAS fpc, PAS gpc, PERL, PERL6, PHP, PIKE, PYTH, PYTH 3.1.2, RUBY, SCM guile, SCM qobi, ST, TCL |
Comments
SUCCESSFUL SUBMISSIONS
Fetching successful submissions


i am getting runtime error in
i am getting runtime error in c++ 4.3.2 and wrong answer in c++ 4.0.0.8 for same piece of code ... is it possible .. coz the basic syntax is same in both.
Why this problem is not
Why this problem is not accepting solution with complexity of O(m*log(n))? Its showing TLE. Admin can you tell me reason.
Can there be more than one
Can there be more than one space characters in between the input data?
Plz Ignore my above cmnt.
Plz Ignore my above cmnt.
Can there be multiple spaces
Can there be multiple spaces or any other white space characters in the input...???
ok...got it..plz ignore my
ok...got it..plz ignore my above comment...
my same solution got accepted
my same solution got accepted in c++4.0.0.8 but am getting runtime error (sigsegv) in c++4.3.2!!!!!
Any ideas???
Getting TLE for a algo of
Getting TLE for a algo of very low complexity . Anybody can tell plz why is it so ..... ???
You're getting TLE because
You're getting TLE because your program doesn't run within the time limit.
Now i m frustated by
Now i m frustated by WA's....... :-x :(
first can be done in O(n) and
first can be done in O(n)
and second can be done in o(1)..
can sum1 explain the sample
can sum1 explain the sample case?
got it ... plzz ignore my
got it ...
plzz ignore my comment
Each integer on a same line,
Each integer on a same line, or between the characters S, Q and the integers is separated by at least one space character.
I'm not a native English speaker but I think there must be some grammar error here, since at least it should be 'intergers are', and I cannot seem to understand this sentence. Not mean to look for any hint here, but could anyone clarify or rephrase this to make this more understandable to non-native English speakers? Thanks a ton!
I dont understand why am I
I dont understand why am I getting a TLE. I'm doing this in (mlogN) time and Im pretty sure there is no faster way to do it!!
Can someone plz explain how
Can someone plz explain how the input is terminating?? is it EOF or just a single input everytime the code is executed!!
Thank you.
does all the test cases need
does all the test cases need to be run within the time limit or is it for each test case??????
i am getting a runtime (NZEC
i am getting a runtime (NZEC error) in Python. What does this error indicate and when does it usually occur?
Please help
There are lots of possible
There are lots of possible reasons.
Segmentation fault , may be in ur case. (just a wild guess ;) )
Is answer in the range of c++
Is answer in the range of c++ long??
There is only one test case
There is only one test case per input file.
I have written a brute force
I have written a brute force program, an optimized program, a random test-case case generator and a matcher. The matcher in C++ forks off child proceses to generate random test cases and runs both the versions and then matches their outputs. I have run 25,000 successful matches but my program (and that of a colleague) fails at around 4.30 seconds. I can see there have been a lot of correct submissions (which is why I was encouraged to write the generator and matcher). I hope the judge and test cases are alright.
I am getting always run time
I am getting always run time error i have test my code ideone.com where i am not getting runtime error please anybody help me.
@Admin: may i have one more
@Admin:
may i have one more test case please???
is ans in unsigned long range
is ans in unsigned long range or no bounds on ans ?
@Admin "output (on a single
@Admin
"output (on a single line) an integer answering to the respective query (follows the respective Input order)."
According to o/p specification it should be int . Admin please clarify.
@rahul, This mean
@rahul, This mean mathematical integer. The result can be as big as possible without any limit.
@Admin I am using Dev
@Admin
I am using Dev C++4.9.9.2
I was able to run my program correctly even for memory allocation of an integer array of size 250,000.
But I got runtime error, which usually happens for too large memory allocatoin(mostly).
Can you please suggest me the exact version of the compiler to use.(I know this is a weired question, but it would be really helpful).
@admin While trying to see
@admin
While trying to see all the submissions, next button doesn't work. is it a problem with my account only?
Due to this problem i cant see the successful codes if not present on that page
am getting runtime error ,