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

Автор komendart, история, 8 лет назад, По-русски

Всем привет!

Codeforces Round #353 (Div. 2) состоится завтра, 16 мая в 19:35 MSK. Я постарался сделать интересные задачи, надеюсь, они вам понравятся.

Хочу сказать спасибо GlebsHP за помощь при подготовке задач и MikeMirzayanov за Codeforces и Polygon.

Удачи!

UPD Разбалловка 500-1000-1500-2000-2500

UPD Разбор

UPD Поздравляем победителей!

Div. 2

  1. mimirrow

  2. Salvare008

  3. orzchimo

  4. student_hh

  5. Pain_Konan

Div. 1

  1. ksun48

  2. sugim48

  3. KrK

  4. cgy4ever

  5. nfssdq

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

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

Надеюсь, условия задач будут такими же короткими, как и пост :)

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

Good luck and have fun

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

Is it rated?


First!!!

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

wow. short and good description. hope to see some interesting problems :)

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

The least words with the most clarity is the best form of expression.

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

komendart and his short announcements

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

Will Codeforces Round 366 (Div 2) be yours?)

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

Краткость — сестра таланта! Как же приятно смотреть на такие анонсы.

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

.

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

    What is misleading about his response?

    • »
      »
      »
      8 лет назад, # ^ |
      Rev. 2   Проголосовать: нравится -20 Проголосовать: не нравится

      .

      • »
        »
        »
        »
        8 лет назад, # ^ |
        Rev. 2   Проголосовать: нравится -13 Проголосовать: не нравится

        deleted

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

        He said that for a valid solution, there has to be at least one nut. This means that if there is no nut, there is no solution. It doesn't mean it is guaranteed that there is at least one nut. His response was clear, so you should blame yourself for misunderstanding what he said. :)

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

    "Please note, that if Bob doesn't make any breaks, all the bar will form one piece and it still has to have exactly one nut."

    I don't find it misleading. This sentence means that it's invalid way if we don't make any breaks and bar hasn't nuts. And this sentence would be excess if it was guaranteed that bar has at least one nut.

    Everyone who asked similar question got this sentence as response. By the way, it can be with the same probability my or GlebsHP's response.

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

    I also failed system tests because I was mislead by the exact same answer you got. I'm still not quite sure what I think about it, it would've been easy enough to just answer yes or no to the question, since people were confused and asking directly, but I guess I just also learnt from it, and from now on will always include an if statement for special case like that if I'm in doubt whether it's in the test cases or not.

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

Зашел посмотреть на прошлый раунд komendart .Полюбовался.Ушел.

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

Best Wishes to All World Final teams. Hope this contest will be warm-up contest for Them.

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

Thank you . It is my first contest . Best wishes for all of you.

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

Simple and clean description :)

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

I really enjoyed your last contest! Thanks for setting this contest.

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

Hope for doing much better.

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

my first time here , hope to see some interesting problems

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

Give me Downvote.........

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

Hope to pass Div2/C for first time :)

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

I don't have internet connection and electricity in my house, had to travel to another city 3 hours away because of contest. Hope the problems are really interesting please.

  • »
    »
    8 лет назад, # ^ |
      Проголосовать: нравится -24 Проголосовать: не нравится

    You must be really excited about Codeforces :)

    It's only a minor contest for most people

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

      If it's minor contest for you, keep it to yourself. Do not discourage others by posting such illiterate statements. It's major contest for all Div 2 contestants who have a chance to increase their rating and eventually end up in Div one one fine day after performing well. !

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

      Well, I'm sorry you feel this way. But codeforces is more than a minor contest. It is a community of dedicated and hard working programmers some of which work for some of the best companies in the world.

      Before joining codeforces, I had did not know about many concepts in programming but thanks to codeforces I now do and am learning and improving daily.

      I made a lot of cool friends here on codeforces and have even been contacted a recruiter through due to my blogging about codeforces.

      So no its not just a minor contest for me. It is a chance to train with different programmers from all around the world and enjoy doing it at the same time.

      Thank you.

    • »
      »
      »
      8 лет назад, # ^ |
        Проголосовать: нравится -7 Проголосовать: не нравится

      šupak(azzhole)

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

What is the most important of it? "Interesting!" I hope I can enjoy it with my friends then, though I am a green hand.

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

Nice and short announcement....fine. :-)

Hope , closing ceremony time will also be as short as the announcement ...... plz

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

We will rise !

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

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

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

My first contest. Feeling Exticed

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

I think one of the problems is about shortest statement :D Have a nice contest ;)

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

Надеюсь контест будет таким же, как и в прошлый раз))

»
8 лет назад, # |
  Проголосовать: нравится -17 Проголосовать: не нравится
Комментарий удален по причине нарушения правил Codeforces
»
8 лет назад, # |
  Проголосовать: нравится -22 Проголосовать: не нравится
Комментарий удален по причине нарушения правил Codeforces
»
8 лет назад, # |
  Проголосовать: нравится +48 Проголосовать: не нравится

Scoring should be 500-1000-25000-500-2500 :)

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

    500 — 1000 — 2500 — 1500 — 2500

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

    I think it depends on perspective. I took 18 minutes to solve C, but 50 minutes to solve D. Mainly due to my inexperience with STL. While the idea for C is a bit less intuitive than D, the implementation is relatively more simple.

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

Submission page is unavailable!!

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

Submit is gone within 8 minutes to end, it's unfair.

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

How to solve problem C ?

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

    Let us note by T[i] the transfer from i to i + 1 in some solution. Then the following equations must be satisfied:

    A[i] + T[i - 1] - T[i] = 0.

    for i = 0, 1, ..., n - 1. Suppose that we know T[0] = x then T[i] = A[i] + A[i - 1] + ... + A[1] + x.

    We can manipulate x and we want the maximum possible number of T[i] to be 0. The best choice for x is the opossite of the most frequent number in the pref_sum table.

    So the answer is n - k where k is the frequency of the most frequent number in the sequence A[1], A[1] + A[2], ..., A[1] + A[2] + ... + A[n].

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

How to solve C? I was finding maximum consecutive zeros(taking circular queue in consideration) and then subtracting it from n — 1. It gave WA on pretest 5.

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

    incorect:

    9
    0 0 0 0 1 -1 0 1 -1

    correct ans: 2
    your ans: 4

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

      i looked for consecutive zeroes that have the same prefix sum and got the best score from: n — number of zeroes with that prefix — number of consecutive intervals. Didn't work, but it does work on this test :(.

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

    test:

    1 -1 0 0 1 -1 0 0 0

    answer is 2

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

    Did you see that it was a circular array? :)

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

    Well, I passed pretest, though I don't know if my answer is correct or not. Here, at first we take cumulative sum in another array, say, cum[i], where cum[i]=summation of initial array from 1 to i. Then, we check for the number which has maximum occurence in the cumulative array.Let the number of times it has occured be max. The answer is n-max.

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

    same here!

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

what is 4th input in E?

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

I'm wondering if there is something very simple we can do for C, or if it was truly as hard as it seemed. Harder than D anyway.

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

My heart was broken.

Unsuccessful hacking attempt -50

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

Very nice problem set!!

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

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

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

Wow system testing started just after the contest finished! so fast! wonderful! :)

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

why I am always forgetting to use long long :'(

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

    You maybe are so excited that you have found the solution, that you don't think about tricky test cases. You just go strait into the code. It's a common mistake. Just make sure you spend 10 seconds thinking about data types that you are going to use in your code when you solve a problem. Spending very little time double-checking your solution is worth getting wrong answer, specially in CF that tricky test cases are not usually included in pretests.

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

I'm curious, as to what your strategies were for C. D seemed more straightforward but C was so interesting I couldn't leave! Mine assumed that there are four optimal starting positions, and I just looped manually. Most likely my assumption is false; anyway what were your ideas?

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

I am getting Time limit exceeded on Pretest 6 on Problem D although my approach is nlogn: http://codeforces.com/submissions/Ishan.nitj

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

Very nice contest, the problems were great, especially problem D. I don't know if I have the right solution though (I didn't send a source :( ), I have a solution involving Segment Trees with Lazy Propagation. What was your solution to D?

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

Hacked 3 times in Div2 A by the same guy... really? Link

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

How to solve D at all? Treap? How to build BST in O(N)? Or some kind of completely another solution?

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

    No treap

    make map of intervals (l; r) -> value at parent list. Initial (0 10^9 + 1) -> -1; 1) read num a;
    2) find interval (l; r) -> ans for which: l < a < r;
    3) if ans > 0 print ans;
    4) add interval (l; a) -> a and (a; r) -> a

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

    Suppose you're adding x. Find a = smallest number bigger than x, b = biggest number smaller than x (between numbers added until now). Now the answer is the one (of a and b) that was added more recently. You can find a and b with a set.

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

System testing was very fast !!!

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

Time complexity for 10^9 passed in codeforces judge when I tried to hack the solution in problem A by giving a=1,b=1000000000,c=1 his code was if(c>0){ while(a<b)a=a+c; if(a==b)cout<<"YES"; else cout<<"NO"; return 0; } But when I provided the test case a=-1000000000,b=1000000000,c=1 I got successful hacking attempt.

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

    on servers 10^9 fast operations go for ~0.8 seconds

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

    I also hacked a solution for TLE, but before doing so I used the Custom Test Tab and saw, that 1 1000000000 1 gives Used: 561 ms, 2036 KB, whereas -1000000000 1000000000 1 gives Used: 1123 ms, 2036 KB and since time limit was 1 second, just the larger test case is valid for a hack.

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

Problem C looks very similar to SRM683 Div1 Easy, O(n) Solution for that problem can be found here. The solution for this problem is also similar

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

Problem D was minor change from a recent HackerRank contest problem, which in turn also appeared in India IOITC 2015 Test 1, and also in some iteration of the COCI(saw it on PEG Judge, not sure which olympiad).

EDIT:

COCI, not CCC, my bad.

  1. HackerRank version

  2. COCI08 #3 BST

  3. India IOITC version

  4. Also on SPOJ, wow

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

Is the contest unrated or we just have to wait some time for the system to update?

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

Why does this code doesn't give RE on 10 10 0?

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

Is the contest rated or unrated

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

    It is rated. I think they are finding the cheaters, my rank just decreased by 2.

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

My hacking attempt on http://codeforces.com/contest/675/submission/17938245 failed for testcase 1 1000000000 1 because the solution produced correct answer in 826ms. So close but yet so far.

-1000000000 1000000000 1 took 1450ms. Should have tried the largest testcase.

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

When do colors change?

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

Hi Friends I am sure this a trivial question, but it would be really nice if someone could look into this. I gave these two submissions 17956219 and 17953624 for problem B div 2. Both are identical except using long long and long data type. But the solution with long gave wrong answer for

100000 2 2 2 2
Output
1410065408
Answer
10000000000

What could be the reason for this?

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

    long = from -2 147 483 648 to 2 147 483 647 long long = from -9 223 372 036 854 775 808 to 9 223 372 036 854 775 807 I made one hack using this

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

    Overflow is the reason. The answer may be 10**10 if sum=10*5 and the number of number that can be used is 10*5. Long data type stores 4 bytes of data whereas long long data type stores 8 bytes of data and 10**10 doesnt lie in the range of long data type. Thus an overflow occured and thus your answer was wrong.

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

    the variable is long long ,but you define int.

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

What a TLE!

I used the generic upper_bound instead of the class specific 17957229 vs 17957298

To have into account in future implementations.

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

    Generic upper_bound on non sorted random access containers takes O(n) time. Protip: google C++ upper_bound.

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

      Yes. In fact I found that reason after google a little bit, then I corrected it. I wasn't aware of that.

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

why in the result table some cells have a color background? http://prntscr.com/b4vv80

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

Thanks a lot for your efforts and interesting problems :)

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

Why ALL my AC code was skipped?The solution gets accepted after resubmitting! Since I didn't use other accounts to submit the same solution or copy others code, how can I ask to retest my code.

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

Great DP in Problem E. It makes proper use of Greedy Algorithm!

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

A splendid round!!!But why not have some weekend round like before?It's really difficult for those students in other regions to get up after 12 during workdays.All in all,just suggestions.

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

Can someone tell me why using array to build BST causes Runtime Error?

I feel a little confused,and my submission was here

I watch others code which use the similar way and find that they also got RE in

test4

input:

10 991309218 517452607 870021923 978357992 136426010 10601767 302627526 883615372 163475700 600546765

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

    Eh, I have not studied BST nicely(one more reason to concentrate in classes :P) but I think you are trying to make a tree using array which will require 2^n space(here n<=100000).

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

The use of unordered_map in problem C leads to a TLE . Why is that ?

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

    Hashmaps have the worst case runtime of O(n) when elements get hashed to the same value multiple times.

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

Please post the Editorial.

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

Завтра оказывается финал ACM ICPC 2016. В CodeForces будет публикация про это? Было бы здорово если бы дали немножко информации про команд которые участвуют в этом году и хендлы участников.

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

WTF why is Problem D statement not available in English?