### maroonrk's blog

By maroonrk, history, 3 weeks ago, We will hold AtCoder Regular Contest 153.

The point values will be 300-500-600-800-800-1000.

We are looking forward to your participation! Comments (37)
 » The whole 2 problems I read were both very good. How do you solve B?
•  » » Congratulations um_nik pulling this 5 seconds before the end of the contest
•  » » One of my classmates use BST.
•  » » Note that for the operation $a\ b$, you can independently flip the indices for the height and the width respectively. So specifically, consider the first sample. We initially start with the indices $[0, 1, 2, 3, 4]$ for the height. When we apply the operation 3, we flip the first 3 and the last 2 to get $[2, 1, 0, 4, 3]$. You can verify that within each row, the original indices of each letter corresponds to this array, both the original position from the top and from the left.So the question is, can we compute these arrays for the height and width efficiently, and then we can just print out the result using these indices. The observation that we can make is that the operation flipping by $x$ is equivalent to rotating the index array right by $x$ reversing the entire array We can also perform the reversal first, which gives us the equivalent set of instructions: reversing the entire array rotating the index array right by $len - x$ (where $len$ is either the height or width depending on which array it is) If we do two operations in a row, then we can do the reversals for both operations one right after the other, so they cancel out. So operation $x$ followed by operation $y$ is rotating right by $x$, then by $len - y$. We can do this to simulate an even number of operations, and if $Q$ is odd, we can just directly simulate the last step.Solution code can be found here.
•  » » 3 weeks ago, # ^ | ← Rev. 2 →   In C++ you can complete all reverse queries with __gnu_cxx::rope in $O(log(n))$. My accepted solution.Reverse $[i,j)$ is equal to swap segment $[i,j)$ in direct order of items with segment $[n-j,n-i)$ in reversed order of items. The rope can erase and insert segments in $O(log(n))$.
•  » » I treat a cell at $(1,1)$ as pivot point. By knowing the position of this pivot cell at the end, we can determine the rest of the positions
 » A binary version of problem D has appeared on codeforces before. Here is the link.
 » When Um_nik becomes rainboy
 » I felt like Problem B was standard. It is simply a straightforward implementation of Treaps. Sadly I don't have a pre-written template for treaps and wasted about an hour finding an easy-to-understand template for treap. C seems nice.
•  » » You can do it without and data structure. You had to figure that rows and columns are independent and final transformation is the cycle of identity permutation.
•  » » Same.I copied this https://codeforces.com/blog/entry/47186?#comment-403709 and converted to C++.Although treap is a overkill as editorial is much simpler
•  » » In C++ you can use __gnu_cxx::rope. AC submission. Comment about this
 » How to solve Problem A?
•  » » 3 weeks ago, # ^ | ← Rev. 2 →   To count up these numbers, start at the first one (110000000). You can't increment the ones place because you also have to increment the hundreds place, which is why the first 3 numbers are increments of the tens place. This means you never should directly increment the ten millions digit, the ten thousands digit, or the ones digit--just their respective counterparts.This means you can take them out of the equation entirely, and simply increment 100 000 N times and then duplicate the applicable digits when printing the answer. codeNote that this problem can be solved in O(1) time similarly--just add 100 000 to N and then use std::to_string to construct your answer. O(N) is fast enough though.
•  » » » still i am not able to understand A
•  » » I use brute force. Since $S_1 = S_2$, $S_5 = S_6$ and $S_7 = S_9$, therefore we only need to iterate 6 different indices in $S$ (only $10^6$ digits possible)
•  » » » can you give the link of your submission
•  » » » »
•  » » » » » ah thanks i understood now
 » Very nice problemset, thanks!
•  » » Congrats ManYou crushed it!!
 » Why did everyone pass B with a splay?????? I feel humiliated.
 » I think many people solve B with data structures.
 » B was a nightmare for me
•  » » Your solution is correct (I implemented it and got AC). There are a couple of things I would like to say: We have 2 cases. If S > R, then we can simply set x[i] = x[i] — (S-R). This should be $x = x - (S - R)$, not $x[i] = x[i] - (S - R)$. If in the end S != R, then if sum of A[i] = 0, we know for sure there is no answer. This is true, but unnescessary. We can just check for answer in the other direction and if there still is no answer found, we print "No". When implementing the code, make sure to use long long instead of int, the integers will get very large. I won't link my code here, because it's messy and I don't want to spoil the implementation part for you. If you need any help, I'll be glad to help!
 » #include #define int long long using namespace std; signed main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int N; cin >> N; vector S(9, -1); N -= 1; S = S = N / 100000 + 1; N %= 100000; S = S = N / 10000; N %= 10000; S = S = N / 1000; N %= 1000; S = N / 100; N %= 100; S = N / 10; N %= 10; S = N; for(int i = 0; i < 9; i++) { cout << S[i]; } cout << endl; return 0; } Where my logic is going wrong?