Hello Codeforces!
I'm proud to announce that Codeforces Round #457 (Div. 2) will be held on 19 Jan, 14:35 UTC. The problemset is authored by southball, longhuenchan and me (STommydx). It is our first round in Codeforces and hope you all find the problems interesting.
We would like to thank the following people as the round would not be possible without their kind help: vintage_Vlad_Makeev for coordinating the round, Arpa for testing the problems and MikeMirzayanov for the great Polygon and Codeforces platform.
The contest will consist of 5 problems and you'll be given 2 hours to solve them. The scoring distribution will be announced close to the start of the round as tradition.
Let me close this blog post by answering the most frequently asked question in Codeforces. This round is rated for all Div. 2 participants. As usual, Div. 1 participants can join out of competition.
Good luck and high ratings!
UPD:
Scoring distribution: 500-1000-1500-2250-2500
UPD2:
We are extremely sorry for the situation for problem B. We are figuring out a correct solution for problem B. I hope you all enjoy the rest of the problems.
UPD3:
The round is over. Congratulates to the winners!
Div2:
Div1+2:
The editorial will be available tomorrow.
UPD4:
Editorial is ready!
Is it the first cf round whose problems are prepared by Hongkongers??
The first "Div 2 Only" contest by Hongkongers maybe... (http://codeforces.net/blog/entry/7390)
Cries in a corner with a div2 problem set.
Why it doesn't appear in the main page? UBD : its Now :D
Finally the wait is over.
Good luck, high rating
I wish a high rating for all.
enough time limit for problems
"Good luck and high ratings!"
Usually after these words there is always something very bad happening.
You're correct as this round is unrated.
You are the true "CF-predictor".
and it happend :D
now the round is unrated
Good luck!
thi cho vui chứ tạch VOI rồi :(
Next time, please use English or Russian in public Codeforces blog posts.
Anyway, there will always be a second chance. Keep fighting, as long as your heart is still on for competitive programming. ;)
(P/s: For those who don't speak Vietnamese, he said he'd play for fun, as he thought he'd fail the Vietnamese Olympiad in Informatics, which occured recently.)
VOI is not the end, ACM is waiting for you.
.... And strong teamates
And a bright future...
... And strong rivals
They mentioned unusual start time in the mail....What's the usual start time?
The problem B's standard solution has a error.
Input:1 7
Output should be -2 -2 -2 -3 -4 -5 -5 instead of -2 -3 -3 -3 -3 -3 -3.
http://codeforces.net/contest/916/hacks/399042
It is the same with 19 5 The answer shoulf be 3 3 1 -1 -1 and it is 3 2 2 1 0
That might be why I always Wrong Answer on pretest 5 For the standard is wrong.
Wow, this is a SERIOUS problem. The round should be unrated.
and its unrated
Wow, I'm right. I've got stuck in B for 30 mins.
Would you please explain the idea behind this?
I got the wrong solution but got passed using priority_queue, just like the standard solution
because -2 -2 -2 -3 -4 -5 -5 is lexicographically greater than -2 -3 -3 -3 -3 -3 -3, and there is no way you can get an answer with the largest number smaller than -2.
Why -1 -2 -3 -4 -5 -6 -6 is wrong?
-1 -2 -3 -4 -5 -6 -6 > -2 -2 -2 -3 -4 -5 -5
y, which is max(Ai) must be minimized. In your case, y=-1, while in second case y=-2. Your y is not the minimum.
I think B is only a greedy problem, try to change the number to binary system, and for a pow(2,m) can split to 2 pow(2,m-1) until the limit reached
Am I right? Can I show my code here?
Why it should be -2 -2 -2 -3 -4 -5 -5 ?
Is it because those are negative numbers?
It should be -1 -2 -3 -4 -5 -6 -6 I think.
edit: no, need to minimize the max value as well
basically a modification of the original idea should work: keep breaking into two till remaining length is greater than current count, i.e. it will lead to a minimum max value.
Then, keep breaking the smaller end.
max(-1 -2 -3 -4 -5 -6 -6)=-1
max(-2 -2 -2 -3 -4 -5 -5)=-2
-1 > -2
agree!
stuck on pretest 5, and i think my code is right.
Exactly, I don't know what Pretest 5 is, but it seems to be very big because I received a RTE when I make my array size very small
The link doesn't work. How did you figure out what the juri's answer is?
The hacks link is invalid until the final standings are published.
should output be -6 -6 -5 -4 -3 -2 -1 of 1 7
no. -2 -2 -2 -3 -4 -5 -5 is correct.
since -2 < -1 (the max value shoudl be minimized)
with 1 7, I had the output: -2 -3 -3 -3 -3 -3 -3
Actually I don't know what is the right answer
I presume you have overestimated the power of Div 2. A bit.
Yes , both B and C are quiet difficult .
C is quiet easy
Is the answer of C fixed?
no, can be multiple, output any.
Wa!! Thanks ,it's really easy!
I tried this, http://codeforces.net/contest/916/submission/34321828
your solution looks correct to me, except your isrPrime function gives 1 as a prime number.
Obligatory rage comment about round being unrated.
How did people manage to get pretests passed on problem B? :D
a priority queue solution passed.
I was getting memory limit exceeded with priority_queue.
Check for some runtime error in your solution. Sometimes undefined behavior causes element to be added indefinitely and hence the memory error. (Its just one of the causes, perhaps the real bug may be different )
https://ideone.com/cyxHGX
You are not at all dealing with cases where no answer is possible. Check out the case "13 2" in sample input of the problem.
Sorry...I edited that...https://ideone.com/1HOrNz
What is the problem? I see you passed systest. Can you please elaborate on whats the problem/issue?
The Problem is when there are negative values.....Input:1 7 Output should be -2 -2 -2 -3 -4 -5 -5 instead of -2 -3 -3 -3 -3 -3 -3...as -3 < -2....
Thats because you are always picking up the max element, popping it and putting in element-1 2 times.
How your queue works is as-
1 i -(input)
0-->-1,-1>>-1,-2,-2-->-2,-2,-2,-2>>> (similarly the 3 of the "-2" turn into "-3,-3" and we reach limit of 7,after which the for loop exits).
What you may try to do is, after the final size is obtained, for any 2 same elements, which are not the max elements, do this-
So, what it will do is, for "-2,-3,-3,-3,-3,-3,-3", the steps will be like-
-2,-3,-3,-3,-3,-3,-3==>-2,-2,-3,-3,-3,-4,-4==>-2,-2,-2,-3,-4,-5,-5.
I think this should be correct (any improvements are appreciated :) )
@vijju123 you cant always do (1).
it might increase your max value. -2 -2 combining to give -1 as the first element.
What you may try to do is, after the final size is obtained, for any 2 same elements, which are not the max elements
I took care of that condition there.
@vijju123 should work
If you write it to do lexicographic ally smallest instead of largest, you will pass pretests.
I did it by priority queue, wrote the output with largest lexi and still pass
absolutely true. I didnt even realize it until u said it
Un...f***ing rated?
Shit, if pretests of B are correct(?) why do you make round unrated?
My solution is passed and I think my solution is correct. Probably there is problem in checker that gave wrong answer on correct solutions which printed something different...
I found mistake in my solution xD
I think the main solution in the problem package were wrong, therefore maybe not all of the pretests have correct answers.
I suppose they were not + even if, there are hacks
Pretest 5 is wrong
Can you explain?
Their solutions probably aren't, so that would affect anyone who wrote a right answer.
pretests aren't correct. yours passed because both are same wrong answer.
I felt that B was a really bad problem...
RIP writer contribution score
Currently it is : -57
whereas it was +1 earlier (google cache), certainly it did fall to rock bottom.
Most unfortunate because of a serious issue. Anyway, still thanks for the contest, other problems were good! ;)
Round unrated but Interesting Problems. Making it unrated in last half hour of the contest is little disappointment.
Fucking shit..How the fuck some people solved B?
I went mad solving that problem.
I think that problem C is easier than B. And both are really cool!
Oh no..It doesnt matter. I wasted my whole contest just to get B accepted. I was not able to think of a logic to sort number lexicographically which does not exceed time limits.
are really shit*
Their mind works like the red coder who coordinated this round.
LOL
emm... I can understand how upset you were after the round declared unrated, but don't you think we should keep a good environment for Codeforces, therefore, no f***ing... And sorry for my poor English...
uhhhhhhhhhhhaaaaaa, I have done 7 successfull hacks and this round will be unrated:)
uhhaaaaa, i'm on the 4 place and this round will be unrated...
I would back Div.1
I think it can be rated for people who got increasing rating.
It would be unfair. Your rating increased even though your code was wrong and ours was correct.
Maybe you misunderstood me or I am really wrong, I mean the rating under the correct tests.
Even though the round will be unrated, I liked the problems a lot! Kudos to the authors!
3 problems got pretest passed and the round is declared unrated!
:( I was frustrated by lots of WA from pB...
Same
My algo for B was absolutely right and the only problem was there in implement lex. sort which was exceeding the time limit.
I went mad when I saw some people solving it with time of about 15ms.
I used a map.It is more easy.
I hate of hearing "The round is unrated" in the middle of the contest and I prefer not to go on.
Kuttar baccha , notir pola , tor bal taina taina chirbo ajke , specialist hoite partam , bal falao ??? jotoshob
Ehe baaje kotha
It's a shame, because D and E seemed like very interesting problems.
Apart from B, I thought the problem set was good (perhaps a little too straightforward with C). That said, I was going crazy trying to figure out how over 1000 people got B.
In any case, mistakes happen, so it's not a huge deal.
lol, E is a boring implementaion
Oh is it? I thought there was going to be some type of clever preprocessing involved. Oh well.
it is boring preprocessing with finding LCA and updating on subtrees,I made it a lot of times
How do you deal with 1st query?
I just remember that this vertex is a New root
E is just cases based on whether lca(x, y) is in the subtree of v or not, and whether it is a parent of v or not right?
E is just a combination of http://www.spoj.com/problems/DRTREE/ and https://www.codechef.com/LTIME14/problems/TALCA.
yes
Ah, so it is LCA. My gut told me LCA but every other time my gut has told me LCA on a tree preprocessing problem it turned out to not be the answer lol.
Is it? I thought it is non-trivial to update subtrees with a dynamic root, and it should takes a few case analyzes to compute the answers based on the pre-computed data structures.
Updating subtrees with a dynamic root is an updating some more subtrees with a constant root
Oh yeah, you are right. I thought it requires HLD to update but it seems precomputing the euler tour is enough.
Not so boring. I learned quite a lot today and implemented new stuff.
D is just boring persistent DS as well?
you're right
What was the issue in B? I did not understand the explanation.
My dream is to be an expert, and the day I have the opportunity, you destroy my dream :(
You're really close to it, so don't worry. If at first you don't succeed, try try again! ;)
No one can destroy your dreams. Except You!
que drama do carai hahaha
interesting problem, anyway, could someone tell me the right solution of problem B? I solve B with the wrong solution, but get passed
You should not write at least the closing line of the blog. :(
D and E are pretty interesting (shoutouts to D) but I think they probably take too much time to code when put together in the same round.
Best comment 2018
Unrated — Predicting
Google Chrome should have this extension
it was a realy good contest despite that problem B
:)
Every fucking time.
Any1 wanna solution for B..
Here it is
https://ideone.com/0HvwUB
thanks
i have solution like this too :D
Plz make the round semi-rated :(
Can D be solved using implicit persistent segment tree?
Even the round is unrated, you shouldn't do this during the round. Am I right?
Not everything that could be made persistent is a segment tree.
Maybe, but i don't know how to deal with condition xi ≤ 109
Making the segment tree dynamic.
I think it can be solved by persistent trie on the values (x(i))
After a week of no contest We got "Unrated" one disappointed :(
Why turning the round unrated?!
Make it unrated for only those who got affected by problem B.
yeah removing problem B from the contest is better than unrating the round
removing problem B isnt a good idea someone who know the correct solution might waste lots of time on it
It'd be unfair to those who spent time on problem B and not on other ones.
how do you know who got affected?
Do you realize you are selfish?
CS Academy just did that on their last round
you're right what CS Academy did is another good way
The reason for you getting high rating is others find the problem is wrong but you not. That is why i speak you are selfish.
but that requires a new checker immediately available for rejudging submissions.
The reason for you getting high rating is others find the problem is wrong but you not. That is why i speak you are selfish.
I wasted 80 minutes on B then moved to C and solved it in 5 mins.
So what will happen to problem B? Will it be deleted or will the solution be corrected?
So next time, Never ask if the contest is rated or not .. Who knows anyways xD
everything is possible :)
B is tough. C is lot easier than B
A and C got AC ;)
is this why B has some mistake :P
when you did your best on the contest and it's unrated!!
Unfortunately both author and my solutions for today's problem B were based on simple, nice (and incorrect) greedy idea so they are incorrect. Now we found correct solution for this problem, but answer for some pretests differs, so it's impossible to make this round rated. Of course I did some stress testing for this problem, but my bruteforce was really slow, so it was impossible to check solutions on most of the tests and greedy idea seemd clear and correct, so there were nothing to worry about. However the most simple greedy is incorrect here (it minimises y, but doesn't produce lexicography maximum sequence). You can check your solution on test "1 7". Answer for it is "-2 -2 -2 -3 -4 -5 -5". Of course we will desribe correct solution in the editorial. We are very sorry about it and will try to make everything to make this not happen again.
=========================================
К сожалению и моё и авторское решение к сегодняшней задаче B были основаны на простой, красивой (и неверной) жадной идее, поэтому они оказались неверны. Теперь мы уже знаем верное решение для этой задачи, но ответ для некоторых претестов был неверен, поэтому невозможно сделать этот раунд рейтинговым. Разумеется, я провёл стресс-тест решений к задаче, но мой перебор был очень медленный, поэтому было невозможно проверить решение на большинстве тестов. Кроме того, решение казалось очень простым и понятным, поэтому ни у кого не было повода волноваться по поводу решения. Однако наиболее простая жадность тут неверна (она минимизирует y, но не выводит лексикографически максимальный ответ). Вы можете проверить своё решение на тесте "1 7". Правильный ответ для него "-2 -2 -2 -3 -4 -5 -5". Конечно мы опишем правильное решение в разборе. Мы приносим глубочайшие извинения и постараемся сделать всё возможное, чтобы это никогда снова не произошло.
is it correct for input 1 7 ? Yes -2 -3 -3 -3 -3 -3 -3
No.
lexicographical order
He mentioned it already. Here " You can check your solution on test "1 7". Answer for it is "-2 -2 -2 -3 -4 -5 -5""
sayedgkm output is same as mine, but it seems to be hard to understand what problem said now
Even though I also made same mistake as the authors and you, and got AC. I believe that this mistake must be only made my idiots like me.
My solution gives -2 -2 -2 -3 -4 -5 -5 which is correct but I fail on pretest 5 so I'm assuming it's one of the pretests that they got wrong
how did you solve?
Consider the binary representation of n For each number i that 2^i is in the binary representation put i in the answer list.
now update the answer list as follows until it's size is equal to K
I am getting the same answer for the aforementioned test. And I was getting wrong answer in test #5. Can you please reveal the pretest #5?
Unfortunately, the writers and coordinator solutions for the problem B are incorrect. The round will be unrated. We apologize.
WTF! -_-
I found problem B very interesting and loved the priority queue solution. I thought it was completely correct and had no clue it could be wrong, so I'm not surprised at all that authors did not realize the incorrectness of this solution too.
Please, don't be angry on them. I enjoyed this round a lot :)
Probably author solution fails in test n=20, k=4. Correct answer is {3, 3, 1, 1} while my passed gave {3, 2, 2, 2}.
Oops, sorry, didn't see above comment of vintage_Vlad_Makeev.
Those red in top 10 who got B correct should be moved back to Div 2.
inb4 dreamoon_love_AA finally gets his long-wanted div2 rank1.
1500+ people did the same mistake as the setter's solution?? :o
good question indeed! :p
The round is rated....
what ?
"... Let me close this blog post by answering the most frequently asked question in Codeforces. This round is ..." 0-rated
On a more serious note, setters should not sub estimate easy problems. I had a similar experience with my problem KNICOV at CodeChef. The moral is that we have to double check greedy problems and have a formal proof.
Come on guys, no need to be so harsh.
Everyone makes mistakes. Maybe they had a rough day and didn't properly check their solutions. Look at the number of up votes for this announcement before and after the UPD.
It is tougher to come up with a quality question than to solve it so we have to appreciate them.
Good job guys!! Make sure you double check your solutions next time ;)
I think the correct answer is more important than rating.
Why "Idleness limit exceeded on pretest 1" in http://codeforces.net/contest/916/submission/34316902 ?
UPD: This happens because I am trying to read an integer in queries and removes
side note: Wouldn't your memory requirement become quadratic? vector ?
The vector just keeps a pointer, so no .
Can someone please explain solutions for problems D and E?
For D, you can use a implicit persistent segment tree to keep the values of the words and another to keep the amount of words with value equals to X.
i know persistent segment tree and implicit treap but what is this implicit persistent segment tree what are it's applications ?
for D, i think just use pbds and some implement... but i didn't do it before the end of the contest
For E, let's solve a simpler problem, suppose you just have to change the root and query the sum in a subtree, if we preprocess the sum of subtrees with the tree rooted at X, there's only three cases to handle when answering queries to a vertex V,
if (current_root = V), the answer is the sum of all nodes
if (current_root in V subtree), the answer is the sum of all nodes minus the sum of nodes in subtree of vertex that leads to current_root in the sons of V
if (current_root not in V subtree), the answer is the sum of the nodes in the subtree of V
To process the updates you have to find the lca(u,v) considering the tree rooted in current_root, the vertex is one of the nodes in {lca(u,v), lca(u, current_root), lca(v, current_root)} and then you process the update similar to the queries, to update a subtree and to query the sum in a subtree, you just need a bit and euler tour.
Thank you. That is quite hard (idea and implementation).
and these are very interesting problems for me
I agree. D and E are very interesting.
How about the system test for B?
Can the first successful submission be considered as the last submission? (for time and for score)
problem setter make bug in problem B program and this round unrated if the solution of problem setter can accept, I think the problem is a good problem But problem D, E are very trouble, I don't think DS and long code and many details can be contest good if the round is div 2 , please problem setter use some hard and not template problem
so if the solution of problem setter can accept B, I also think this round should be unrated
the contest value > the contest rating :)
Nice contest dudes too bad it's unrated but the problems were good!
Alternatively u guys can fix B prroblem description to "Of all satisfied sets with elements sorted in non-increasing order, print out the lexicographically smallest one. THEN greedy sol would be correct.
Can you please explain why this would work for lexicographically smallest one.
Common guys mistakes happen. Don't discourage problem setters
Is it good idea to change statement of problem B — only minimize max(a_i)? In this case problem is good for div2B and all solutions will get ok.
Yes , Then the question gets quite easy right , just calculate the exponent of 2 for which (2^exp)*k >= n (i.e all k terms are exp initially) and exp will be the max a_i and decrease the remaining a_i's such that sum = n and print them .
Lesson to problem setters: If you are including a greedy problem, write a Formal proof of it. If you say after contest that the greedy solution seemed correct, I think it straight away implies that there was no formal proof written / verified.
Pretest 5 of Problem B gives me another chance to look my life again, how almost competitors wrong here?
"It's a div2B so 90% of the time it doesn't require deeper thoughts" <--- Probably why
It was the first experience of contest setters. Sure, in the next time they will make better contest. Everything is ok.
You guys need to calm down a little bit. In the end, this is just one round that, in the long run, will have very little impact on your life. Everyone makes mistakes. There's no need to curse out the problem writers, who clearly worked hard to make interesting problems. I can't imagine the difficulty it takes to write a set of problems that have absolutely no flaws in them, and most people complaining can't either, since Div 2 people rarely write rounds.
It's not the end of the world if one round you were doing well on goes unrated. If your performance was part of a trend, you'll do well on future contests. If your performance was an outlier, then future contests would have corrected your rating anyway.
Because problem B and the unrated contest they got more than (-100) on this post
Actually I still don't know how I can receive a WRONG ANSWER ON PRETEST 5
we will see after testing ends.
it's -135 now
Before contest: About +190 or higher
After unrated: wait for it...
why system testing is too slow ? -_-
1) So many hacks on A
2) So many submissions on A
Problem A has more than 250 test cases! :/
UPD: it's my fault
For problem E, is it:
?
Yes
worked on B for quite a long time but can't solve. feel released now.
Over 250 test cases for problem A... personally I think 50 would be enough and thanks to that judging time would be much shorter :P
Can you please reveal the test #5 of problem B?
I wish I was the writer of this round, so I can get a lot of downvotes.
Very cool round!(no)
You end up in fourth in the contest and then the contest was declared unrated, so sad
you know that you are not in div2,right?! :))
How to solve D and E ?
i don't get the point of putting Persistent Implicit segment tree in the D problem if someone has a decent template of it he can solve it in a little under 30 minutes i think putting a problem that required more thinking would have been better.
i don't get the point of putting Euler Tour Tree in the E problem if someone has a decent template of it he can solve it in a little under 30 minutes i think putting a problem that required more thinking would have been better.
Don't you guys think that putting a persistent data structure problem on Div. 2D is not suitable ? I was going to compete in a Div. 2 contest for fun. However, got stuck on problem B and D........ :(
I agree with you.I have no idea to D and E. They are not friendly to us newbies.
I also made lots of small mistakes when I held a small contest in my school for the first time. So I believe the tiny flaws of this round are acceptable. I wish the authors,coordinators and testers will prepare a better round the next time.
Coincidentially I was first exposed to "persistent" data structure problems was also a div2D.
http://codeforces.net/problemset/problem/707/D
I remembered I saw a problem which is several yrs old and is a div2E. It's just dfs order. Now it is dfs order + segment tree + lca. So we can conclude that the average intelligence of human beings is increasing right? haha
ваша тестирующая система некорректно работает, у меня ответы все правильные которые вы выдаете за неправильный ответ!!!
expected that situation after phrase "He has got an idea for a problem, but does not know how to solve it."...