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

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

SnackDown 2018 elimination round starts in ~8 minutes. Top 300 get T-shirts

Let's discuss the problems after the contest!

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

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

Is it possible to move SRM?

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

How to solve ADIMAT, XORTABLE and EBAIT?

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

Any ideas what we may have missed in EBAIT? We even wrote stress test...

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

How to solve all the questions?

Is this what happens when you are out of touch for months or were the contest problems really difficult?

»
8 лет назад, скрыть # |
 
Проголосовать: нравится +69 Проголосовать: не нравится
rep(i,0,n) {
    if (i%2==0) cx+=v[i];
    else cy+=v[i];
    if (i==n-1) continue;
//  if (i==n-1) --cy;
    if (cy*mx>=my*cx) {
        mx=cx; my=cy;
    }
//  if (i==n-1) ++cy;
    }

That's a part of 1st place team's AC submission to problem "Election Bait". As far as I understand, phrase "For each bus except the last bus from the last convoy, after the people from this bus cast their votes, party A must have strictly more votes than party B." means exactly what is written in commented lines. Can someone explain this?

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

Looks like the data (or statement) for EBAIT is incorrect. In the statement it says for all bus except the last one in last convoy, A has more votes than B; however most solutions understand it as for all buses not in the last convoy, A has more votes than B. We stuck on this problem for more than 3 hrs.

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

Also I guess it's Radewoosh's time to joke about "notorious coincidence".

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

SFXPAL may be solved in linear time using . Did anyone use it? Can anyone prove it? :)

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

This is directed towards Codechef organizers: I am going to explain why team azneyes (with ksun48) and moofest (with me) have basically the same code on ADIMAT.

We were both on MIT ACM last year, and did GP of Poland. We both recognized that the problem was the same as there, so we both copy and pasted our AC code from there. That's why the code is the same.

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

Problems from OEIS, from e-maxx, from recent contest — well done Codechef, it was one of the worst contests ever.

Is the Codechef coordinator green or cyan?

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

So is something going to be done with Election Bait? In a situation when the statement is inconsitent with the test data, accepting all solutions that solve the problem correctly in at least one of the sensible settings seems like a fair thing to do.

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

    Accepting all solutions that solve the problem according to the in-contest version of the problem statement (and changing either the statement or test data, whichever is more practical) seems like the best course of action, yes.

    UPD: Should I take downvotes to mean nothing should be done? ( ͡° ͜ʖ ͡°)

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

      Sorry, but this looks like wrong understanding. The way proposed by Endagorion was to accept solutions to both versions of the problem, not to pick one of them. So that the accepted solutions stay accepted, but additionally, the currently rejected solutions get rejudged with jury answers being answers to the other version of the problem. It requires some work on the organizers' side.

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

      It gets even worse because some of the translations may be entirely different kinds of wrong. For instance, the Russian statement misses any kind of formal explanation of the process (it just basically says "the party A should be winning until the very last moment", sic).

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

        It shows that there should be no translations for important international rounds, unless organizers can really ensure the quality.

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

        Translations are sometimes made using early versions of statements (before I completely rewrite them). Long Challenge started yesterday, so I had 22 problems to work on and only edited EBAIT today. Still, translations are there just for convenience and if someone gets something wrong because of not reading the main problem statement, that's just too bad.

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

          In the preelimination contest earlier this year there was a bug in russian statement. The numeration of sides of the triangle is clearly different

          https://www.codechef.com/SNCKPE19/problems/ANGLE

          I prefer not to read translated statements since then :)

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

          What's the point of making them if you have to read english statement anyway?

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

            Agree. These creepy translations should be deleted. Some things are just too bad to exist.

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

            You have to read the English statement if you want to be 100% sure what's going on. It might be simpler for people to speedread statements in their native languages. But idk, I don't decide that.

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

              Since you brought up the long contest, in this month's challenge problem, the English statement does not explain how the input is generated but the Russian and Hindi translations do.

              It seems that to be 100% sure you understand a CodeChef problem, you have to read the English statement and the translations.

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

                The input in the challenge problem is generated in a secret way. Thanks for telling me, it should be removed from the translations — it can lead you to optimising your program's performance on wrong test data without realising it. (Go ahead and give me an implementation of connect().)

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

                  That's interesting, I heard the contest admin said the exact opposite: that the pseudocode will be added to the English statement as well, and to look at the translations in the meanwhile.

                  Glad this came up now when there's still plenty of time left in the contest to clarify things.

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

                  Of course, when I say something will be done, that's just what I think will/should be done. The translations are updated now.

                  If you think about this generator description, there isn't any area where it clearly tells you something. It doesn't let you reproduce tests with an identical distribution, since connect() is secret. It doesn't exclude any types of tests because the baseline is a random DAG and connect() is secret. OTOH, how tests are formed clearly affects the solution somehow (or it wouldn't be secret), which is something people might miss. It's better to avoid saying something misleading about test data.

                  The main problem with keeping translations accurate, especially when a small correction is made in a statement, is resources: time and people. Think about it, who will check the translations? Are translators supposed to monitor everything and triple-check for differences? I don't know any TL languages except Russian, so that's out. Problemsets are made late since there aren't enough setters, which means testing is often rushed, things change shortly before the contest, and sometimes something gets missed. Translations are the last part of the expected process "initial statement -> changes during testing -> final statement -> translations", and of course, when you parallelise, it's much easier to miss something. Plus consider that people who do everything have their own lives, for example I have a full-time job and usually fix statements in evenings when I have free time. If I'm on a trip somewhere with no net, you might get crap statements; this ties up to the "not enough time" problem.

                  In the end, the situation can't improve unless more good problems are proposed — that would push the whole workflow ahead. There are small improvements like more people checking everything, or not so many shitty non-statements where I have to divine what the setter wanted to write, but they don't affect so much.

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

          translations are there just for convenience

          In most serious competitions I've seen translations are treated as formal documents with equal power as official statements. If that is not the case, there probably should be a notice of that (e.g. "there's no guarantee our translations have anything to do with actual problems, idk lol").

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

        In Chinese statement for SFXPAL we're told to modulo the answer with 1e9+7 instead of M. Luckily I guess most participants have noticed the extra number M in the input.

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

Problems were very interesting, enjoyed it quite a bit, even thought they were very difficult for me. If someone could elaborate on Adi and the Matrix it could be nice ^^

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

    You have to use burnside lemma. THe group acting on the set of all binary matrices is (P, Q), where P and Q are permutations of length m and n respectively. Say the cycle lengths in the permutations are (l1, l2, ..., lk) and (L1, L2, ... Lr) respectively.

    Now we have to find the number of binary matrices unaffected by the pair (P, Q). We will choose some Xa, b and rest will be set through equality conditions. For example, say we choose some index a from a cycle of length li and index b from cycle of length Lj. Then setting Xa, b will set values. So overall, we have to set values to set all values for indices from the cartesian product of two cycles. Hence there are binary matrices fixed by the permutation pair.

    Now, assume n < m and for each partition of n, do a dp on the other dimension. The overall complexity is O(m2p(n)) or O( where N is the constraint on nm and p(n) is the partition function. Link to solution

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

How to solve ADITREE ?

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

OK, so here's my turn to ask something about EBAIT. Not adressing issues connected to this problem, how did you manage to solve it? I see that many teams solved it, however it still seems to me like a really hard problem. I tried to solve it using pretty complicated black box that tells me number of lattice points in first quadrant below line with equation Ax+By=C. This black box is rally tough, but fortunately we had it prewritten, but I still didnt manage to fully solve the problem since I got lost in ocean of formulas. mnbvmar used some algorithm from Wikipedia about continued fractions, but this seems really weird to me and Errichto used some freaky Python function that solved it for him, both of these approaches look nothing at all how I would approach such problem (maybe that's why I didn't solve it?)

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

    well, continued fractions seems to be reasonable directions to start from because they give you best approximations of things (with small denominators) and you want to get a good approximation to the start of interval(which is less then end of an interval)

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

    A way how I see this problem:

    You basically have the following inequalities:

    • for some integers

    • for some integers

    After some hard math I managed to get this:

    So you need to find between and . I used Stern–Brocot tree to find the closest to the root fraction that lies between L and R. You can also use this.

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

    It's called Stern-Brocot tree. If you google "Stern-Brocot tree site:codeforces.com", you can hopefully find this post where you can simply copypaste.

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

    How about this: Try all denominators up to min(C2, 10000), compute the minimum numerator for each. If you didn't find a solution, try 1000 random denominators. If you still didn't find a solution, declare that none exist. AC in 0.05s.

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

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

      So, there's no testcases where there's a single denominator which fits and is quite big (~1e9)? Sounds like bad test suite to me.

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

        Can they be made? How about an extended version with trying numerators up to 10000 too?

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

          Well, I'm not sure, but something like this should work:
          Let's get some fraction p/q, approximate it with all the denominators from 1 to c2 from the top and from the bottom. Get closest from both sides and set them as two borders.

          Of course, you'll also need to construct testcase itself (didn't think whether it's trivial)

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

            a b c d should give a range (b / a, (b + d) / (a + c)), so at least any range with max-fraction having the bigger numerator and denominator is doable. When we account for irreducible fractions, that gives even more.

            When the range of allowed fractions is very tight, I'm thinking of some solution that discards ranges of numerators/denominators that clearly have no solution within the given range...

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

              yep, so if you have p/q and r/s and p,q,r,s <= 5e8, you can always make s > q by multiplying both r and s with some constant. It will mean that r > p automatically.

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

        Well, test suite was very weak for sure. For example naive solution with Farey sequence worked despite TLing on very small test like

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

    There's a way to compute the number of points in integer coordinates inside the triangle (0, 0), (n, 0), (n, (a/b) * n) in O(log(A + B)) with a modified Euclidean algorithm. This is the same as computing the number of points in integer coordinates under the line y * b — x * a <= 0 for 0 <= x <= n. I used this to do binary search to find the first point between the two half-planes.

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

When will t-shirts be sent?