Starts in less than 24 Hours.
Author is Errichto
Also check : http://codeforces.com/blog/entry/57011
Please do not upvote my SRM blogs. I don’t want my contribution sky rocketing for something I do not take credit for. I only aware you so you don’t miss SRM’s like I did when cgy4ever ( or in the past, Chrome) stopped posting them.
Edit: Problem Analysis (Except Div1 1000 ) by alei : https://aleigorithms.wordpress.com/2017/12/10/srm-725/
Starts in few hours.
Redoing this blog as it appears people liked it last time. (If there is someone from TC that prefers to post these kind of blogs, I will happily delete this).
Hello recently I attempted this problem: http://codeforces.com/contest/341/problem/D
I understand editorial's solution, but I found in comments a very nice solution, that appears it can be generalized to query sums or higher dimensions. Here is it.
Notice that we could do + and - subtraction interval-wise. But Fenwick tree could only update per range and query per element or vice versa. If, for each element, say, ft(x, y) hold the sum of prefix sum of the matrix (1, 1, x, y) (ie. prefix sum of prefix sum of (x, y)), then for each query, ft(x1, y1) - ft(x0 - 1, y1) - ft(x1, y0 - 1) + ft(x0 - 1, y0 - 1) would be the result. As the difference between prefix-sum is the sum of the corresponding interval. And it's easy to xor a v to elements in submatrix (x0, y0, x1, y1). Consider 1 dimension version of this problem. For a sequence a, the prefix sum of x is and the prefix sum of prefix sum of x is . Hence, all we have to do is to maintain an extra sequnce i * ai. Then expand method above to arbitrary dimension.
Link to code : http://codeforces.com/contest/341/submission/4391987
I could only get a vague idea, but not much into detail of what's going on especially the code. With this being a 4 years old comment, I don't think it's a good idea to ask the guy who posted, but can anyone please clarify in an easier way, or provide similar problems/blogs to it? Perhaps how to solve this problem if it was for sum queries instead of xor using this technique.
Topcoder SRM 723 starts tomorrow.
I only created this blog because cgy4ever stopped doing them. I always disliked knowing about SRMs before they start by like 1-2 hours so thought I'd post about it a day in advance. ( If there is someone from TC that prefers to post these kind of blogs, I will happily delete this).
I was recently solving this problem : http://www.spoj.com/problems/KOPC12B/
The problem statement is just one line, so no need to rephrase it.
Knowing the solution to the problem without weights, and printing consecutive values, I guessed the answer to be n*C(2n,n)/2 after some trial and error and was surprised it passed.
I tried to arrive at a combinatronics proof by trying to pose the problem as counting binary strings with certain properties, but didn't get somewhere noticeable, I also tried changing (C(n,k)^2) to C(n,k) * C(n,n — k).
Any help proving this? Thanks.
I was recently solving this problem : http://poj.org/problem?id=1823
The problem basically says given an array of maximum size of 16000 where each element is one or zero, we need to perform the following two operations.
-Set range [L,R] to ones or zeros.
-Query maximum length of a subarray of ones
The problem can be indeed be solved by a segment tree, however using bitset we can do updates in O(N/32), and with N being 16000 that's just 500.
The problem is in querying the maximum length, I haven't reached any solution better than N operations, are there any ways to achieve something like N/32 ?
Please note, I already know the segment tree solution, I'm interested in bitset.