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

Автор Errichto, 8 лет назад, По-английски

Hi everybody.

The IndiaHacks finals will take place tomorrow (on Saturday). The contest is being organized by HackerEarth. Just after the official finals, the CF round will start (check-your-time) with almost the same problems. You can treat it as a standard CF round — there will be 5 problems in each of 2 divisions, and 2 hours to solve them. Two divisions will compete together on the problem set with 7 problems, with 2 hours to solve them.

I want to especially thank I_love_Tanya_Romanova for testing the problems, GlebsHP for help with making the CF round possible, and MikeMirzayanov for his awesome attitude and for the Polygon system. Setters: Lewin, k790alex, Sokolov, Errichto. Testers: I_love_Tanya_Romanova, Errichto. Small help: belowthebelt, raviojha2105, johnasselta, Radewoosh. And my big thanks to HackerEarth for inviting me to Bangalore, it's truly a vibrant city.

Some info only for 40 official finalists — Remember not to discuss anything until the CF round ends (so, at least 2 hours after the official contest ends). You will find all important information at link-to-the-contest. You can ask me questions by PM on CF or on HE, and I will put answers in the "Challenge Details" at the link provided. Do not use comments here because it can only confuse others. You can use some old blog about the IndiaHacks semifinals if you want to discuss something.

I wish you great fun and no frustrating bugs. Enjoy the contest.

Scoring: 500-1000-1500-2000-2500-3500-3500.

WINNERS

  1. jqdai0815, the only one to solve all 7 problems!
  2. JoeyWheeler
  3. jcvb
  4. andrew.volchek
  5. ikatanic

In the official finals there were technical issues with the stack size (it was again only 8MB) and constraints in E weren't correct at the beginning. We want to fix it as much as possible, without any guessing though — we can't say how much time did you waste because of something. If you were affected then write to me PM with the description of the situation. Your time penalties will be canceled (and maybe some earlier submission will be accepted, if only the stack size didn't allow you to get AC).

Editorial is being created here.

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

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

So the official finalists lose a rated contest? Or is there a way to add ppl to the standings afterwards and let them be rated?

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

    Yes, they do lose a rated contest. It's impossible to add them to the leaderboard, too many differences in the problem set.

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

    most of them will probably lose two rated contests if they are competing on-site

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

      The top 19 or so won't be competing onsite. World level vs country level...

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

We always expect some photographs in these onsite contests :)

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

A rated div2 contest after a long time.

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

Welcome to India Errichto! :)

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

Idk why, but March is so adored by different cups and competitions. It's hard to take a part in all of them, especially (speaking about me) because there is some All-ukrainian competition in this time too (I'm talking about Math and Informatics). So, can someone explain me why March is so adorable?

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

Note changes in the blog — the contest will be combined for two divisions. Make sure to register again.

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

It's goodbye 1394(in Iran)
Happy new year(1395) :)))

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

I think these 2 contests (CROC & IndiaHacks) are closer time-wise in history of codeforces.

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

Thanks for Announcement .

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

The name of this contest is "IndiaHacks" and none of the writers or the testers of this contest are Indian. Not that I am saying it's a problem but it feels a little weird.

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

Still decreasing in Div 1 after 6 months :(

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

"The duration is 2 hours. I will try to inform you about the duration in a few hours."

Just in case the duration will change again.

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

Will the format be ACM or standard CF?

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

    It's never written about ACM, so I think it will be standart CF

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

I submit a hack but get Unexpected verdict.I want to know what happened.

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

I feel many submissions will fail in B. Will generating all strings give time out? And can it result in int overflow?

PS

My submission was running too slow for this test case

6 26

aa a

ab a

ac a

.. .. till az a

PPS — I was wrong. I forgot that we can only use a,b,c,d,e and f.

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

Such a difference between B and C. I think in B condition "a.i!=a.i for all i!=j" makes the problem much more easy

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

Anyone can share his idea about D/E?

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

    D. Max-flow with some tricks: Binary search on the answer. For answer being tested edge capacity equals maximum number of bears that can go through it. Calculate max flow. If it's more or equal than number of bears — such answer is achievable.

    E. Let's consider graph with all non-forbidden edges (G). G' = G with vertex 1 removed. Proposal: Answer is possible if and only if following conditions are met:

    1. Degree of vertex 1 in G more or equal than k.

    2. Number of connected components in G' is less or equal k.

    3. Each connected component in G' is connected to vertex 1 in G.

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

    In D, I did the following:

    1). I used binary search on the answer.

    2). How can we check if we can use this weight?

    2. 1). Calculate the weight that one bear carry. It will be totalWeight / x.
    
    2. 2). Now, for each edge, we can count how many bears can go through this edge.
    
    2. 3). Count maximum flow. The weight capacity of the edges in the graph will be the values we've counted in 2. 2).
    
    2. 4). When we've counted maximum flow, it will be maximum count of bears. If this value will be more or equal than x, then the bears can carry this weight.
    • »
      »
      »
      8 лет назад, # ^ |
        Проголосовать: нравится 0 Проголосовать: не нравится

      I used the same approach but I am getting WA on test 44. Its because of precision issue, but I do not know how to handle this. LINK Correct answer: 1.000000 Output: 0.99991126

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

        You should change condition in binary search. Now you EPS = 10^(-9) * x Correct condition is (Math.abs(r — l)*x / (Math.max(r,1)) > E)

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

          Very old bump, but can someone explain the WA44 here? I don't get why my solution also only outputs 1 to 4 or so not 6 decimal places

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

    D: Binary search on doubles the check with maxflow if you can travel to the end with each bear's weight equal to the current middle in the binary search.

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

There is a strange bug(?) happening during contests. Whenever I'm seeing someone's solution, and this solution is hacked or resubmitted, a message pops up and I automatically log out.

This happened in yesterday's contest too.

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

When will start system tests?

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

How we can solve C simply?

I checked 7 possible states!!! :(

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

    Iterate through the array if you found a bad index i then you must swap i or i + 1. So try swapping i and i + 1 with the rest of the array and check if each swap will fix all the bad indices.

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

      OH MY GOD , thanks!!! My brain stopped in the contest. How stupid am I !!!

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

How to solve C? :)

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

    I think that you can find all "invalid" positions (d[i] <= d[i+1] or >=, whatever), and brute force to "fix" it with swapping with any other position. It's not hard to see that invalid positions cannot be too many (i set limit = 9, but should be <= 6 or smth), and you need a O(1) checking then.

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

      Ohh sh*t, that is actually too easy, thanks!

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

      I timed-out when trying all swap combinations, I never thought to only check bad indexes! :(

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

      How did you deduce that the number of invalid positions would be less than 6?

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

        We touch only two numbers. Let indices be i and j. Proposal: swapping them can fix only positions {i — 1, i, i + 1, j — 1, j, j + 1}. So if we have more than 6 "bad" positions, some of them will still be unfixed.

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

      Hello can you suggest similar problems! I fail on such easy to "see" problems.

      I knew that 4th was binary search with max flows but I don't know much about any algorithm of Max Flow so couldn't solve it! I was solving C yesterday using ternary search( I didn't knew much theory about it ) and couldn't debug (although I had that sliding window in my mind) I switched to D but was unable to deduce the fact! So Probably I am having very bad contests these days! I think I should take a break :/

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

    Considering positions i and i+1 as invalid if sequence[i] >= sequence[i+1], for odd i, or if sequence[i] <= sequence[i+1], for even i.

    You must notice that if there are more than 6 invalid positions then a single swap won't fix it, so you output 0.

    When there are 6 or less invalid positions just test all possible changes with them.

    The complexity is O(6*N) if you check if one change makes the sequence nice in O(1).

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

Looks like problems in the Codeforces round are significantly easier than those in the HackerEarth round.

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

    is it bad?

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

      Well, this round was initially announced as an online mirror of IndiaHacks Algorithm Finals, but now it looks more like a different contest. Also, because the problems are different, it is not possible to easily compare results of this round with those of the official participants, and discussing problems is also more difficult because some problems are different, and all the problems are in a different order.

      Not to mention that I spent some time solving problem E with a wrong constraint.

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

The period of waiting for systest to begin, is painful. They lock problemset and all. Maybe next time I'll contribute too so they can get more servers and keep them open for generic solving >.>

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

What is the idea for problem D ?, I tried to solve using binary search the maximum amount of weight one bear can deliver and check if it's possible using fordFulkerson. But I am getting WA in pretest 6. Am I missing anything ?

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

Damn it, integer overflow in D!!!. T^T

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

How to solve D. I figured out that if I obtain residual graph and after that find flow from each edge which is leaving source node than I have to distribute 'x' bears over them. But how to do it? Or I started wrong?

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

Summary of HackerEarth problems:

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

    How to solve F from this problem set?

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

      If I'm not mistaken, if you already have a valid flow for x0, then the answer for x0 + 1 depends on the least amount of wood each bear needs to lose to create a new augmenting path from source to sink. If you compute, for each edge in the residual graph, how much wood each bear would need to lose to be able to send one extra bear through that edge (it can be 0 if the capacity is not full), then this is equivalent to finding a path from source to sink with the minimum maximum weight, which can be solved in O(E log V) by Prim or Kruskal.

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

        It seems to be true. Thank you!

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

        Yeah, that's how I solved this problem. The algorithm looks more like Dijkstra though, with the sum replaced with maximum. I tried to find the initial flow in the same way, but it didn't pass TL, so I had to add binary search.

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

    my solution for B( codeforces) and E ( hackerearth) has a complexity n*26*q .code

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

      Your program doesn't solve E from hackerearth.

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

        Is there any way to access the problemset from onsite ? I tried looking at hackerEarth recent contest but couldn't find anything.

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

Human stupidity at its finest: taking 50 minutes to notice a compilation error -.-'

(I'm so happy I did it before the contest ended, though :P)

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

    I know that feel bro, same sh_t with MLE, so now I catched -27 to my rating

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

    Wow so you just submit and don't wait to see whether you passed the pretests?
    #justgrandmasterthings

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

      I usually think so:

      "I`m not going to waste my time on waiting, see later"

      trying to solve next problem

      forgot about previous

      "OH WAIT WTF"

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

    I had a similar issue.

    I've noticed that I actually got TL for C only after successful submission for D. I'm pretty sure that I've seen "Pretests passed" for C and I think that it is the issue of twitchy status line that can change from "Running on pretest 7" to "Running on pretest 3" and back several times before showing an actual verdict. That's pretty sad :(

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

Why didn't my submission fail?

This line is wrong according to me

z.pb(a[k]+c[j][i-3]);

It should be

z.pb(a[k]+c[j][0]);

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

A total rating gain of 1 in last 24 hours

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

12 Legendary grandmasters! :D

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

Lol

Hashes with modulo = 264 passed :)

16814596

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

    Time limit for this problem was intended to be 1 second or 2 seconds for slow languages like Java to avoid these kind of solutions.

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

jqdai0815 rating looks like typical track in Gravity Defied now

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

I have got WA 2 for Problem C.

But locally with gcc 4.9 and on ideone.com with C++ 14 this code on this test was executed correctly.

http://codeforces.com/contest/653/submission/16816483

What's wrong with this code?

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

Somehow, tests for D allow to search only for blocking flow, not for maximum. Compare this accepted solutions: 16816698, 16816675 on next test:

4 5 2
1 2 3
2 3 3
2 4 2
1 3 2
3 4 3

(outputs are about 3 and 4, second one is correct).

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

There is a overflowing bug in my code of problem D.

My code will fail on the following case:

4 3 100000
1 2 2
2 3 1000000
3 4 2

And some other participants also passed the system test using int to store the capacity of edges.

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

What are results of onsite(?) round?

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

Если я не ошибаюсь, то задача F была один в один на Петрозаводском контесте пару лет назад. Вроде это был контест от tourist.

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

HackerEarth scoreboard.

Remember, HackerEarth has different problems.

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

Can you guess or prove why does it work?

Problem E solution. 16820873

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

    I suppose the testset in E is pretty weak. My original solution was too slow... so I just done some hacks in order to pass pretests: 16814798. I was super surprised when it was accepted on the main tests, because I'm almost 100% sure it's wrong.

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

      Have you tried to find some tests?

      I tried but has not found.

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

        Yes, for my solution I can came up with simple test on ~50 vertices (constant that I use in the code) that will fail. Essentially, there will be one bridge that connects one separate vertex to the fully connected component, and all the edges except one from this component to this vertex will be prohibited. Then this edge won't be discovered and the vertices will be considered disconnected.

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

Another suspicious North Korean code!

http://codeforces.com/contest/653/submission/16815024

http://codeforces.com/contest/653/submission/16811842

I think those codes are really identical — simply some names are the difference (ex, 'doit' <-> 'foo', 'xvalue' <-> 'dat')

I actually didn't really care about those stuffs before, but my 2599 rating makes me bit sensitive. MikeMirzayanov, can you investigate these deeper?

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

    Says the South Korean...

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

      Regardless of nationality, The fact remains :)

      (And the desire for IGM also remains..)

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

    Is it possible that this is some sort of template or part of an official solution to an earlier (North Korean) problem?

    Also, it's interesting that those nearly identical submissions still make a difference of 15 ms.

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

      It's not possible that this is some sort of template — problem E from this round wasn't that typical. Considering the huge simillarities between those two submission (they only replaced some name) maybe they were a part of an official solution, but then there is no way to punish cheaters (since the same logic belong to any cheated code). So this should be decided upon other reasoning like previous decisions.

      Also, "completely identical" submissions can easily make a difference of 15ms, so IMO it's not that interesting..

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

Will be tutorial?

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

Editorial Please!!!

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

wrong answer 1st numbers differ - expected: '1.0000000', found: '0.9999918', error = '0.0000082'

What a sad story :((

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

What's the meaning of dsu? I can see it in Problem tags sometimes.

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

Why has the round been made unrated ?

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

Errichto And India
Thanks for coming to India. I hope you had a great time.
Image1
Image2
Image3
Image4
Image5