Блог пользователя zscoder

Автор zscoder, история, 10 лет назад, По-английски

Important Update: Our friends have noticed that the upcoming round collides with their contest and also weekend is full of many another contests, so the round is now moved to Monday, 29 August 2016 15:05 MSK. We are sorry for the inconvenience caused and hope that you'll understand us.

Hi everyone!

Codeforces Round #369 (Div. 2) will take place on 27 August 2016 at 16:05 MSK. As usual, Div.1 participants can join out of competition.

I would like to thank danilka.pro for helping me with the preparation of the round, MikeMirzayanov for the amazing Codeforces and Polygon platforms and also Phyto for testing the problems.

I am the author of all the problems, and danilka.pro also helped making one of the problems harder. This is my first round on Codeforces! Hope everyone will enjoy the problems and find them interesting. It is advisable to read all the problems ;)

In this round, you will help ZS the Coder and Chris the Baboon while they are on an adventure in Udayland. Can you help them solve their problems? :)

Good luck, have fun, and wish everyone many Accepted Solutions. :)

UPD : Also thanks to IlyaLos and HellKitsune for testing the problems too.

UPD 2 : There will be 5 problems and the scoring is standard : 500-1000-1500-2000-2500.

UPD 3 : Editorial

UPD 4 :

Congratulations to the winners :

Div. 1 winners :

  1. matthew99

  2. uwi

  3. Egor

  4. Um_nik

  5. kmjp

Div. 2 Winners :

  1. zhabo

  2. ysy_ioi_pengbei

  3. YangJunzhao

  4. lych_cys

  5. Zharaskhan

  • Проголосовать: нравится
  • +286
  • Проголосовать: не нравится

»
10 лет назад, скрыть # |
 
Проголосовать: нравится +21 Проголосовать: не нравится

Timing although nice collides with Codechef lunchtime (•_•)

»
10 лет назад, скрыть # |
 
Проголосовать: нравится +53 Проголосовать: не нравится

Since it's impossible for everyone to have a positive rating change, I wish high rating for everyone who deserves it and has been working hard.

»
10 лет назад, скрыть # |
 
Проголосовать: нравится +32 Проголосовать: не нравится

Good to see zscoder start writing regular rounds now. I wonder what interesting problems he has in stock.

»
10 лет назад, скрыть # |
 
Проголосовать: нравится +48 Проголосовать: не нравится

I wish not to see "unrated user" in top_10

»
10 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Auto comment: topic has been updated by zscoder (previous revision, new revision, compare).

»
10 лет назад, скрыть # |
 
Проголосовать: нравится +2 Проголосовать: не нравится

Auto comment: topic has been updated by zscoder (previous revision, new revision, compare).

»
10 лет назад, скрыть # |
Rev. 2  
Проголосовать: нравится +4 Проголосовать: не нравится

Time not collide with contest lunchtime... Please don't play with my feelings.

UPD : Nevermind, Thanks for update...

»
10 лет назад, скрыть # |
 
Проголосовать: нравится +3 Проголосовать: не нравится

Could you please postpone the contest a little bit? Something like 19:00 MSK would be great for everyone, because some of us are still working at 15:05 MSK.

»
10 лет назад, скрыть # |
Rev. 2  
Проголосовать: нравится -15 Проголосовать: не нравится

Is the contest delayed for 3 days or is this a bug/mistake ?

»
10 лет назад, скрыть # |
 
Проголосовать: нравится -19 Проголосовать: не нравится

Will problems be in russian language?

»
10 лет назад, скрыть # |
 
Проголосовать: нравится +2 Проголосовать: не нравится

contest time change .....:(

»
10 лет назад, скрыть # |
 
Проголосовать: нравится +1 Проголосовать: не нравится

The first thing that I saw here was arithmetic-progression tag :/

»
10 лет назад, скрыть # |
 
Проголосовать: нравится -6 Проголосовать: не нравится

Where is contest tomorrow?!

»
10 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Thanks a lot zscoder i was just wondering how i would be able to give 3 contests with time colloiding with each other in a single day + i have an annual day also tomorrow of cse society and as last contest cost me too much -ve rating and i want to become expert again so can't afford to miss a regular round....

U solved my problem and also of many i think...so thank u so much zscoder:)

»
10 лет назад, скрыть # |
 
Проголосовать: нравится -8 Проголосовать: не нравится

Thanks, Monday is better!!

»
10 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Hopefully not a stupid question. What contests are there overlapping?

»
10 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Oh now I won't be able to participate anymore :( sadlife

»
10 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

"wish everyone many Accepted Solutions", that's a joke right !?

»
10 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

why change the contest to 8.29??????excuse?

  • »
    »
    10 лет назад, скрыть # ^ |
     
    Проголосовать: нравится 0 Проголосовать: не нравится

    This is because of the many contests that are being held in this weekend (one of which clashes with the original time) so this is to allow everyone to have a chance to participate in all of them instead of being forced to choose between the clashing contests.

»
10 лет назад, скрыть # |
Rev. 4  
Проголосовать: нравится +9 Проголосовать: не нравится

your problems in educational round are always among the most interesting problems I've ever met. Hope your round will be interesting too! 710E - Генерация строки 691E - Xor-последовательности 665E - Красивые подмассивы 678D - Итерированная линейная функция

»
10 лет назад, скрыть # |
 
Проголосовать: нравится +5 Проголосовать: не нравится

Please try to give a constant time for next rounds...

»
10 лет назад, скрыть # |
 
Проголосовать: нравится +54 Проголосовать: не нравится

this guy has 2 Bronze medal in IMO
his results
so...

»
10 лет назад, скрыть # |
 
Проголосовать: нравится -26 Проголосовать: не нравится

Why this round delay?

»
10 лет назад, скрыть # |
Rev. 2  
Проголосовать: нравится 0 Проголосовать: не нравится

1.29 August 2016 15:05 MSK.
2.27 August 2016 at 16:05 MSK.
3. Aug/29/2016 18:05UTC+6.
Which is perfect time??????

»
10 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Perfect timing of a contest...:-) thanks for shifting the contest.

»
10 лет назад, скрыть # |
 
Проголосовать: нравится +7 Проголосовать: не нравится

List of Contest, if someone need (^_^)

»
10 лет назад, скрыть # |
 
Проголосовать: нравится +5 Проголосовать: не нравится

Awful time. It's a middle of working day in Europe!

»
10 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Where is our Gleb? :P

»
10 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Auto comment: topic has been updated by zscoder (previous revision, new revision, compare).

»
10 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Great , I'm so happy , Monday I can participate !!

»
10 лет назад, скрыть # |
 
Проголосовать: нравится -20 Проголосовать: не нравится

كل تاخيره و فيها خيره :D

»
10 лет назад, скрыть # |
 
Проголосовать: нравится +12 Проголосовать: не нравится

Chinese people will be glad to participate this round. It's on 20:05! The earrrrly time means we can almost see the rating changes!

»
10 лет назад, скрыть # |
 
Проголосовать: нравится +1 Проголосовать: не нравится

I love arithmetic-progression :D

»
10 лет назад, скрыть # |
 
Проголосовать: нравится +25 Проголосовать: не нравится

can U please put the contest 2 hour later? i and 37 of my friends are in class in this time and we really want to participate in this contest! thanks!

»
10 лет назад, скрыть # |
 
Проголосовать: нравится +8 Проголосовать: не нравится

Keeping the previous problems in mind which are provided by the problemesetter zscoder in various educational round , i hope that today's round is going to be fantastic, wish you all positive rating change :)

»
10 лет назад, скрыть # |
 
Проголосовать: нравится +7 Проголосовать: не нравится

Again 7k+ contestants :) i hope there won't be long queue!

»
10 лет назад, скрыть # |
Rev. 2  
Проголосовать: нравится 0 Проголосовать: не нравится

Contest time is so bad, I hope change it to the usual Codeforces rounds time :(
(there is electricity outages in Syria in this time :p)

»
10 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

pray for being specialist .!

»
10 лет назад, скрыть # |
 
Проголосовать: нравится +3 Проголосовать: не нравится

Auto comment: topic has been updated by zscoder (previous revision, new revision, compare).

»
10 лет назад, скрыть # |
 
Проголосовать: нравится +1 Проголосовать: не нравится

7.5k regitered users, hope there won't be a large queue..

»
10 лет назад, скрыть # |
 
Проголосовать: нравится +10 Проголосовать: не нравится

could you delay the contest till i finish my ice cream

»
10 лет назад, скрыть # |
 
Проголосовать: нравится +22 Проголосовать: не нравится

First round exceeds 8k

»
10 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

How many people feeling lazy for contest?

»
10 лет назад, скрыть # |
 
Проголосовать: нравится +8 Проголосовать: не нравится

More than 1000 unrated users :/

»
10 лет назад, скрыть # |
 
Проголосовать: нравится +17 Проголосовать: не нравится

WOW!! 8000+ contestant already registered.

»
10 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

8385 registration !!! Is it the highest ever ? WOW... way to go CF.. Love this platform.

»
10 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Very cool problems. (I liked problem C and D more)

»
10 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

let's wait and see how many div2 B solutions will fail at test n = 1

»
10 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

How to solve E ?

Wilsons theorem ?

  • »
    »
    10 лет назад, скрыть # ^ |
     
    Проголосовать: нравится 0 Проголосовать: не нравится

    Div1E:

    (B - A) / B = (2N - 1)(2N - 2)...(2N - K + 1) / 2N(K - 1)

    The denominator (B) is a power of 2, so for it you just need to count how many 2s you need to remove both from A and B (using modular inverse!). For (B-A), you can compute it straightforwardly in a loop but early break if you get 0.

  • »
    »
    10 лет назад, скрыть # ^ |
     
    Проголосовать: нравится 0 Проголосовать: не нравится

    I get hit by pretest 4 so I probably missed out some exceptions in my last few minutes, but I strongly believe that my approach is correct.

    For B, the value is (2^n)^k (before modulo 1e6+3, of course), it is not hard to prove, since there are (2^n) days and k people in the set, so this is the total case.

    Denote A' as B-A, this value is (2^n)! / (2^n-k)! as we consider that the days are not clashing with each other.

    To calculate A', you can just use a for loop from (2^n-k+1) to (2^n) to get the value, note that since MOD = 1e6+3, when you hit something that is divisible by MOD, just return 0.

    The only part I failed is to make A' co-prime with B by counting the 2's in the for loop, but note that I am using values that are under modulo MOD so the amount of 2's are not exactly correct.

  • »
    »
    10 лет назад, скрыть # ^ |
     
    Проголосовать: нравится +9 Проголосовать: не нравится

    The combinatoric(probabilistic) problem wasn't too hard.

    Answer is

    The real problem i think is compute this value modulo mod.

    Notice than when k >  = mod the term that involves factorials is equal to 0, so answer isn't that hard in that case, but remains the problem of reduce the fraction. The only prime factor of the denominator is 2, so you need to find the biggest p such that 2p divides the numerator. Then multiply both num and den for the multiplicative inverse of this number and voila...

»
10 лет назад, скрыть # |
Rev. 2  
Проголосовать: нравится +14 Проголосовать: не нравится

Hats off to zscoder for such an awesome problemset, especially problem D :)

»
10 лет назад, скрыть # |
Rev. 5  
Проголосовать: нравится 0 Проголосовать: не нравится

I solved A , B in 16 minutes and didn't solve C. It seems like it is very easy as a lot of people solved it. But how did you handle something like that ? (3 3 3)

(0 0 0)

(1 200 200)

(1 1 1)

(1 200 200)

With my approach it was so hard to be handled because after the putting the colors that will give me the minimum cost I start to change the current beauty to be beauty + 1 or beauty -1 in every step until I reach set == k.

But this case will require from me to change the beauty by 2.

»
10 лет назад, скрыть # |
 
Проголосовать: нравится +8 Проголосовать: не нравится

Couldn't submit D because the servers were slow during the last 60 seconds ;_;

»
10 лет назад, скрыть # |
 
Проголосовать: нравится -14 Проголосовать: не нравится

*Reads Problem E

*Notices a way to calculate large factorial is needed

*Ready to rant for requiring knowledge about an algorithm that I probably won't need it again.

*Notices that since MOD is only 1e6+3 so things could be simplified at the last minutes

*QWERTYUIOPLKJHGFDSAZXCVBNM obviously didn't coded quick enough and fail

Keep on observing till the last moment guys...

This is a pretty decent problem set anyways, I'm lovin it. =]

»
10 лет назад, скрыть # |
 
Проголосовать: нравится +5 Проголосовать: не нравится

What was pretest 7 at D?

»
10 лет назад, скрыть # |
 
Проголосовать: нравится +1 Проголосовать: не нравится

I tried to hack this 20246021 twice, as it uses int but he gives the correct output and no overflow happened!!

could anyone explain why that happened?!

  • »
    »
    10 лет назад, скрыть # ^ |
     
    Проголосовать: нравится 0 Проголосовать: не нравится

    Your hack is wrong, I guess. Operations on 32 bit integers normally wrap around. Can you share your hack with us?

    • »
      »
      »
      10 лет назад, скрыть # ^ |
      Rev. 2  
      Проголосовать: нравится 0 Проголосовать: не нравится

      the 1st hack the 2nd hack

      what do you mean by "Operations on 32 bit integers normally wrap around", could you explain that?

      • »
        »
        »
        »
        10 лет назад, скрыть # ^ |
         
        Проголосовать: нравится +3 Проголосовать: не нравится

        Take a look at this. Normally the result of addition, subtraction and multiplication on ints will still be correct modulo 232. And if the final solution is less than 231, the calculated value will be correct.

        The problem with the second code is that the compiler is able to deduce that the loop will result in undefined behavior, so the compiler can basically do whatever it wants. In the first code, the compiler cannot deduce anything (because of user input) and no weird "optimizations" will occur. The machine code generated will simply use the ADD x86 instruction (or perhaps the MUL instruction), which on x86 produce the correct result modulo 232.

        I warned everyone not to expect such crazy undefined behavior (for example when hacking solutions) but I got booed off

    • »
      »
      »
      10 лет назад, скрыть # ^ |
      Rev. 2  
      Проголосовать: нравится +6 Проголосовать: не нравится

      10

      0 536870913 536870913 536870913 536870913 536870913 536870913 536870913 536870913 1

      536870913 1 536870913 536870913 536870913 536870913 536870913 536870913 1 536870913

      536870913 536870913 1 536870913 536870913 536870913 536870913 1 536870913 536870913

      536870913 536870913 536870913 1 536870913 536870913 1 536870913 536870913 536870913

      536870913 536870913 536870913 536870913 1 1 536870913 536870913 536870913 536870913

      536870913 536870913 536870913 536870913 1 1 536870913 536870913 536870913 536870913

      536870913 536870913 536870913 1 536870913 536870913 1 536870913 536870913 536870913

      536870913 536870913 1 536870913 536870913 536870913 536870913 1 536870913 536870913

      536870913 1 536870913 536870913 536870913 536870913 536870913 536870913 1 536870913

      1 536870913 536870913 536870913 536870913 536870913 536870913 536870913 536870913 1

      This is the case I found.

»
10 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

I figured out the solution for problem D. Unluckily couldn't complete the code on time.

It is easy using DFS to find the number of edges that form the circle, let's name it cEdge.

Notice that if we choose the sets that contain the circle edges, after flipping, the circle remains.

So the answer = Number_of_all_subset — Number_of_subset_doesn't_contain_all_circle_edge = Pow(2,n) — 2*Pow(2, n — cEdge).

It this solution were right, I would be a little bit sad. Cause this is the first time I was this close to problem D.

»
10 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Please help me with the second question (Div. 2) and tell me what I did wrong? http://ideone.com/6HDQwQ

»
10 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Wasted a lot of time on B and C, I think I could have solved D if I was a little faster :(

»
10 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Auto comment: topic has been updated by zscoder (previous revision, new revision, compare).

»
10 лет назад, скрыть # |
Rev. 2  
Проголосовать: нравится 0 Проголосовать: не нравится

Almost everyone has implemented a O(n^4) dp for problem C,I just hope it doesn't pass else it would be very unfair..how could 10^8 iterations pass...there are many problems on codeforces where a similar complexity has given TLE.

»
10 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Can anyone explain C ?

»
10 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

http://codeforces.me/contest/711/submission/20254708 Some one please tell me why this timed out ?

»
10 лет назад, скрыть # |
 
Проголосовать: нравится +6 Проголосовать: не нравится

Я видимо один в B проявил фантазию и написал:

if( n == 1 ) {
    cout << 4815162342 << endl;
    return 0;
}
»
10 лет назад, скрыть # |
 
Проголосовать: нравится +1 Проголосовать: не нравится

Rant: Hate it when forgot to uncomment a line that i commented out during debugging

But atleast it shows up in pretests xD and i could fix it :D

»
10 лет назад, скрыть # |
 
Проголосовать: нравится +15 Проголосовать: не нравится

C was the first DP problem that I've solved during the contest thank you zscoder

self-confident level is rising.

»
10 лет назад, скрыть # |
 
Проголосовать: нравится +8 Проголосовать: не нравится

Finally, I am going to be blue! :D

»
10 лет назад, скрыть # |
 
Проголосовать: нравится +1 Проголосовать: не нравится

Problem B was so tricky

»
10 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Pain is solving 4 problems and then getting "WA on 105" _/_

»
10 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Не, ну я так не играю. Полчаса думал, как div2::C за куб решать, а в итоге и за 4 степень у всех зашло :(

»
10 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Auto comment: topic has been updated by zscoder (previous revision, new revision, compare).

»
10 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Can someone tell why did I get WA on 105.
http://codeforces.me/contest/711/submission/20244876
Its not clear from the test case what's wrong.

»
10 лет назад, скрыть # |
 
Проголосовать: нравится +1 Проголосовать: не нравится

Can someone tell me what's wrong with my code? 20239552

»
10 лет назад, скрыть # |
 
Проголосовать: нравится +1 Проголосовать: не нравится

Yes!!!! Specialist finally...next target :- Expert

»
10 лет назад, скрыть # |
 
Проголосовать: нравится +3 Проголосовать: не нравится

O(n*k*m^2) in C! Really? 10^8? I didn't believe that it will pass all the tests and wrote something strange... Now I don't understand how my code passed pretests. Anyway, problems were very nice. Thank you

»
10 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

I like the problem c,my dp is weak.i didn't solve it in contest,the problem c help me improve my mind,and the time is really really nice, thanks a lot

»
10 лет назад, скрыть # |
Rev. 2  
Проголосовать: нравится 0 Проголосовать: не нравится

Hi.

This is about Problem B. I'm stuck at the test 93, and the test data is:

3

1 15 5

11 7 3

9 0 13

The correct answer is 1. However I think the answer should be -1.

Could anybody explain this for me?

Thx.

»
10 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Problem C I though n*k*m^2 couldn't pass so I didn't do the solution. New lesson of analyzing bigO notation

»
10 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

I have a tendency of writing recursive solutions for DP problems. Will that be cause any problem in near future? Here is my accepted solution for DIV 2C (Complexity O(NKM2)). Can anyone help how to modify the same recursive solution so that complexity is reduced to O(NKM).

  • »
    »
    10 лет назад, скрыть # ^ |
     
    Проголосовать: нравится 0 Проголосовать: не нравится

    I have been told that it is always better to have an iterative code because it is easier to make sure you don't compute the same thing twice and you can have stack overflow with a recursive function. But I am no expert if someone knows it better ...

    • »
      »
      »
      10 лет назад, скрыть # ^ |
       
      Проголосовать: нравится +13 Проголосовать: не нравится

      Good day to you!

      I think it is (in MOST cases) up to you [what fits you better].

      The advantages of "iterative" method are, that is is faster (by a constant — not that much but it is SOMETHING).

      The "stack problem" is usually on, only if it is "1D" Dynamic Programming with N greater than 10^5 — anyway it can be prevented by executing DP a few times (you can execute the recursion with 10^5,2*10^5,3*10^5...etc in a loop, so there won't be more than 10^5 depth {or you can do this with custom depth — it doesn't cost any asymptotic complexity :) })

      The same thing will never be computed twice (in any of the methods), anyway a "thing" might be asked more than once in recursive form (anyway as it is computed it ends in O(1) )

      I (personally) prefer recursive method over iterative [it is easier for me to see the solution] — but as I said, it is personal matter.

      An advantage of recursive DP is, that it is more easy to do a DP, in which the whole "state-space" doesn't fit into array, but you will use only "part" of it [with assist of "map"]. Also it is more easier, whenever the parents are somehow "variable" — not fixed :)

      So the asymptotic complexity of both methods is same, and most of the things can be (somehow) converted to other method to make it working — so unless you are (for a reason) hunting every "ms", then it is only matter of personal preferences!

      Good Luck & Have Nice Day :)

»
10 лет назад, скрыть # |
Rev. 2  
Проголосовать: нравится 0 Проголосовать: не нравится

nice

»
10 лет назад, скрыть # |
Rev. 2  
Проголосовать: нравится +5 Проголосовать: не нравится

Is there a bug in the contest ?!
Rating changes are removed !! zscoder MikeMirzayanov

UPD : The bug is fixed now.

»
10 лет назад, скрыть # |
 
Проголосовать: нравится +4 Проголосовать: не нравится

did the round become unrated ?! or is it just a bug ?

»
10 лет назад, скрыть # |
 
Проголосовать: нравится +5 Проголосовать: не нравится

11 days till the next contest !:/

»
10 лет назад, скрыть # |
 
Проголосовать: нравится +1 Проголосовать: не нравится

it's really frustrating that next contest is 10 days away.