We will hold AtCoder Beginner Contest 146.
- Contest URL: https://atcoder.jp/contests/abc146
- Start Time: http://www.timeanddate.com/worldclock/fixedtime.html?iso=20191124T2100&p1=248
- Duration: 100 minutes
- Number of Tasks: 6
- Writer: beet, kort0n, kyopro_friends, tempura0224
- Rated range: ~ 1999
The point values will be 100-200-300-400-500-600.
We are looking forward to your participation!
It would be better if someone post English editorial of AtCoder contests!
Although they do not have English editorials officially ( yet!, hopefully they will in the future ), but Geothermal usually writes his solutions in English, and posts them shortly after the contest. So you should read them, it is very helpful.
Oops same answer at the same time. xd
Haha, yeah. I was surprised too. And it seems, we both gave each other a +1 xD.
There will be a blog after the contest by Geothermal sharing his/her approach in English.
I've written an English editorial: https://codeforces.net/blog/entry/71701
I have done so as well. :)
https://codeforces.net/blog/entry/71699
Thank you!
You guys are saviors.
For problem C Can someone tell me what is wrong in my code I got WA in one test case
Anybody else found this contest somewhat easier than a normal beginner contest?
Very nice of you to say that ! Thanks! :D
That's not me, it's Yoda.
So I would say — "Thank you Master".
can Somebody please explain to me more Problem E ? I have read both of the tutorials and still don't get it. Thank you
Firstly, we store prefix sums, to get range sums in O(1). Now, notice that $$$[L, R]$$$ interval is good if $$$Pref(R) - Pref(L-1) \mod K = R - (L-1) $$$.
This means, $$$R - (L-1) < K $$$ — (1)
Also, rearranging a bit we get, $$$Pref(R) - R$$$ = $$$Pref(L-1) - (L-1) \mod K $$$
So, we make a new array ( let's call it F ), such that $$$F(i) = Pref(i) - i$$$.
Then, number of required intervals ending at index $$$i$$$ are number of $$$j < i$$$ such that $$$F(j) = F(i)$$$, and $$$i - j < K$$$
Let's make a map, storing frequencies of elements of array $$$F$$$.
Moving from left to right, at index $$$i$$$ you will have information from $$$i-K+1$$$ to $$$i$$$ (sliding window). Then just add frequency of $$$F(i)$$$ at each index.
My submission ( I have done the same thing, but from back to front ).
I have a question for the last line of the hint. Shouldn't it be F(j) = F(i) mod K?
Ah yes. I was calculating everything modulo $$$K$$$. I forgot to explicitly write it.
Actually, the main jist is that, you have to do all calculations modulo $$$K$$$, the only inference was that you should only consider subarrays ( or contiguous subsequences, as questions states ), of length at most $$$K-1$$$.
You should explain what you do understand and don't understand, and/or what step in someone's editorial you can't follow.
(Otherwise there's nothing stopping someone else from posting yet another explanation that you don't understand, which isn't helpful to them or you.)
Thanks for the reply. I am not saying you haven't explained well. I just coudn't understand and I know it's my fault cause apparently it's too easy for many people. I get the part where there has to be Pi≡Pj but what I don't get is how to get all the pairs verifying this condition ?? and about the condition you montionned do you mean that the maximum number of elements should be less than K ?
Thanks for explaining what steps you wanted to know more about!
Let me try to explain those parts. Let's solve the reduced problem: given an array $$$p$$$, find all pairs of equal elements that are at most $$$K$$$ apart. To do that, let's count all the pairs $$$(i, j)$$$ (with $$$i<j$$$ and $$$p_i=p_j$$$) for a given $$$j$$$. Given a fixed value of $$$j$$$, we count the number of indices $$$i > j - K$$$ such that $$$p_i = p_j$$$ (which we can do efficiently using a hashmap to keep track of the counts for each $$$p_i$$$ in the past $$$K$$$ indices). If we add up all these numbers (loop over each $$$j$$$), we end up with the total number of pairs. This is because every pair $$$(i, j)$$$ is counted exactly once, when we count all the valid $$$i$$$s for that $$$j$$$.
Does that help?
Hi all, for problem F, I did a (too simple) implementation. It obviously fail, but the problem is that I am not able to understand why it should return a shortest path that is not the lexicographically minimal. This is my code:
I cannot identify a negative pattern to proof that this fails :( Is there a way to download/see the testcases, after the ATCoder contest terminates?
Thanks a lot for any help
std::reverse(out.begin(), out.end()); You actually reverses the "string", not the numbers. For example, "1 12" becomes "21 1" from your code, but it should be "12 1". Then the rest of your solution is correct.