Wellcome to Codeforces Beta Round #91! This time, the author of the round will be me, Herasymiv Vitaliy (witua). Thanks a lot to Artem Rakhov (RAD) for helping in round preparing and Maria Belova for problems translation. I hope you will like problems.
Thanks all! And here are the winners:
I hope I will increase my rating as well by positive "lucky" number.
Is there any place here, where noobs can ask stupid questions?
May be your blog is a such place, but if care about your "contribution" you'd better to ask Google first :)
What IDE/OS do you use?
I am using Visual Studio on Windows. It would be fun to write such a tool, I am up to it, unless it is not implemented yet (which would surprise me actually).
You're welcome to implement and share it :)
Partly because I'm very sleepy, I don't like those `lucky number' problems, by the way. I shouldn't have participated :-(
The idea of four being a lucky number sounds a bit odd to me, because where I live the number four (in fact even numbers in general) is considered to be very unlucky.
This is tradition from Lviv, Ukraine.
1. When you find the a 4-7 in a odd position
>>If there is only one 7 in front of it than just replace the 7 with 4 and continue searching.
>> If there are more than one 7 like(124777) you'll stuck in a loop(124777-->124477-->124777)
2. When you find the a 4-7 in a even position
>>If there is a 4 behind the 47(like 6447) you'll stuck in a loop.(6447-->6477->6447)
>>other wise you can just replace and continue searching.
in case of "replace and continue" i increment "step" by 1. When i stuck in a loop i just check how many steps left and determine the final string from it. The complexity is just o(n).
Hope this helps.
I assume you mean div 2 problem D. The idea is, that once you encounter the string "447", where the second 4 is at an even position it will keep looping with 447 -> 477 -> 447.
If a such string is not present the amount of operations that can be done is O(n).
You thus run through the string and when encountering a 47 you check if it's in odd or even spot. If it's in an even spot you check for the terminal condition (above). If this isn't a terminal 47 we can just do the operation and either move one step forward or one step backwards depending on odd/even.
Can anyone share idea of div1 C?
Can you please explain how do you generate the k-th permutation of SIZE numbers using O(SIZE) memory and O(SIZE * SIZE) time?
Notice that 10^9-th permutation can shift no more than 13 last numbers.
First, count number of happy numbers that could not be shifted - they all stay on their places, happy places.
After that, generate K-th permutation, apply this permutation to last numbers and find indices of happy numbers among last numbers.
upd: so many replies)
But what's the point of having hacks if there are trick/corner cases on pretests?
Not only on pretests but also on the examples. However it depends on the author which corner cases he decides to reveal. Sometimes the difficulty of the problem can vary a lot depending on the pretests and the examples.
UNFORTUNATELY , i had a stupid mistake and got wrong answer on 30th test . I have never written any contest with no silly mistakes thats why i am in 2nd division again :(((
For problem E in div 1, is block-array solution expected to pass? My code in the contest had some minor bugs, however I modified and it worked in practice (for example, 809913)
Right after the contest, I submit my code with O(nlogn) for adding and O(logn) for counting (using BIT) and get AC, that's really surprising!
5' ago, I resubmitted the same code and got TLE on test 62.. :(
The complexity of block-array solution seems to be O(m*sqrt(n)*log(sqrt(n)*2^10)? I don't know whether it can solve this problem without enumerate every lucky number
I am wrong， I didn't see the condition
Why is 799 almost lucky? (122A)
Cause it can be divided by 47.