Pa_sha's blog

By Pa_sha, history, 3 hours ago, In English

2008A - Sakurako's Exam

Tutorial
Solution in C++
Solution in Python
Rate the problem

2008B - Square or Not

Tutorial
Solution in C++
Solution in Python
Rate the problem

2008C - Longest Good Array

Tutorial
Solution in C++
Solution in Python
Rate the problem

2008D - Sakurako's Hobby

Tutorial
Solution in C++
Solution in Python
Rate the problem

2008E - Alternating String

Tutorial
Solution in C++
Solution in Python
Rate the problem

2008F - Sakurako's Box

Tutorial
Solution in C++
Solution in Python
Rate the problem

2008G - Sakurako's Task

Tutorial
Solution in C++
Solution in Python
Rate the problem

2008H - Sakurako's Test

Tutorial
Solution in C++
Solution in Python
Rate the problem
  • Vote: I like it
  • +15
  • Vote: I do not like it

»
2 hours ago, # |
Rev. 9   Vote: I like it +15 Vote: I do not like it

Great problem E. I had a little fun and leaked the solution with a useless if statement (that makes no logical sense and that is wrong): if < 2: print(best + 2) and just a bit above that a if n == 1 so that it would still AC even though there is something useless and wrong. This will make it easy to report cheaters. This is a new thing I think we should all do. Leak solutions with easy to spot but hidden watermark for those who don’t understand the algo. https://pastebin.com/VSP4VCne

we just need to crawl all AC and check those with a if n < 2.

This is an example of a cheater that would have never been caught otherwise: https://mirror.codeforces.com/contest/2008/submission/279191114 Because he or she was clever enough to really rework my solution.

Spoiler
  • »
    »
    3 minutes ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Great work lmao

»
2 hours ago, # |
  Vote: I like it 0 Vote: I do not like it

In problem F, I guess it should be "divide" instead of "delete first value by second" :)

»
2 hours ago, # |
  Vote: I like it +3 Vote: I do not like it

Great round, I loved G and H very much.

Anyways, I read E wrongly during the round and I assumed we can do deleting operation as much as we want. Can anyone solve it? (if you can solve that, you can solve E easily.)

Spoiler:
  • »
    »
    98 minutes ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    I solved the same misread on E initially

    It is straight forward dynamic programming after fixing the alternating string characters

»
106 minutes ago, # |
  Vote: I like it 0 Vote: I do not like it
  • »
    »
    33 minutes ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    try implementing dfs without funtion

    may be recurion calls is taking time;

»
102 minutes ago, # |
  Vote: I like it 0 Vote: I do not like it

In the problem G tutorial there should have been k = k — a2 + a1 + 1 instead of k = k — a2 + a1 — 1

»
100 minutes ago, # |
Rev. 4   Vote: I like it 0 Vote: I do not like it

In C , Can be solved in $$$\mathcal{O}(\sqrt{r-l})$$$ and can be optimized by binary search in $$$\mathcal{O}(\log (r-l))$$$ using

$$$\frac{n(n+1)}{2}$$$

, and can be optimized to $$$\mathcal{O}(1)$$$ by quadratic equation , Check 279123925

Overall nice contest Pa_sha orz

  • »
    »
    95 minutes ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    because no one should be solving A like that

    • »
      »
      »
      87 minutes ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      Optimization when not needed Bad solutions when not intended

    • »
      »
      »
      25 minutes ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      At least I solved C assuming $$$(1 \le l,r \le 10^{18})$$$

  • »
    »
    87 minutes ago, # ^ |
      Vote: I like it +1 Vote: I do not like it

    I don't think that last linked submission of yours is constant time. It uses the sqrt() function.

  • »
    »
    25 minutes ago, # ^ |
      Vote: I like it +1 Vote: I do not like it

    Hi. Your solution for A cannot pass because it is $$$O(t\cdot (a+b)\cdot 2^{a+b})$$$ which is a lot. On maximum tests it is $$$100\cdot 20\cdot 2^{20}$$$ which is approximetly $$$10^9$$$.

    For C you are right. In fact, $$$O(\sqrt{r-l})$$$ is okey for Div3B, so we didn't take it away.

    Thanks for your feedback

»
95 minutes ago, # |
  Vote: I like it 0 Vote: I do not like it

please someone explain to me in problem: 2008G — Sakurako's Task. Why the gcd of all numbers is the key, I cant see the idea behind.

  • »
    »
    76 minutes ago, # ^ |
    Rev. 3   Vote: I like it +1 Vote: I do not like it

    So there is a basic concept. If I give you 2 numbers like 2 and 3 and say you that you can use 2 and 3 any number of times and you can either add them or subtract them then what are the possible numbers you can generate.

    Answer :- You can generate any integer from 2 and 3.

    Reason :- GCD of 2 and 3 is 1 therefore you can use 2 and 3 to create 1 (3 — 2)

    Now for any integer x you can generate it by using (3 — 2) x times.

    Now take 2 and 4 for example. Their gcd is 2 so you can generate 2 from them (4 — 2). Now you can generate any even number from its gcd by repeating (4 — 2) any number of times but you cannot make any odd number using it.

    Go in G after taking gcd of all, suppose gcd is x therefore optimal array to form will be [x, 2x, 3x, ... ]

    Sorry if I made you more confused by my explanation but if your doubt is not cleared I will try to explain with a different approach.

»
90 minutes ago, # |
  Vote: I like it +11 Vote: I do not like it

Updating the tests instead of the model seems like the wrong decision to me (i am biased though)

The last few cases I remember of a wrong model (but there exists a solution), they fixed the model and rejudged the solution

Can you explain why it was not done like that here? I remember an edu round and a div2 round where we got rejudged midcontest after the model was fixed

Vladosiya Pa_sha

Relevant meme :

Situation : Unit tests are failing

Vladosiya and Pasha : delete the unit tests

  • »
    »
    86 minutes ago, # ^ |
    Rev. 2   Vote: I like it 0 Vote: I do not like it

    Also, Why isnt there more discussion on this?

    Authors fucking changed constraints midway but a slightly too hard div2C gets more hate???

    • »
      »
      »
      76 minutes ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      You don't need to curse or be rude every time. You're not umnik, and will never be.

      • »
        »
        »
        »
        74 minutes ago, # ^ |
          Vote: I like it 0 Vote: I do not like it

        you would be pissed off too if you spent 30minutes wondering where your code might go wrong and then it turns out authors cannot write a correct model.

        I do not want to be a umnik, i want to be myself. Cursing comes naturally to me and I dont see the need to restrain from it.

    • »
      »
      »
      42 minutes ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      is the div2C ur talking about from recent div 2? cuz i haven't been active lately

      • »
        »
        »
        »
        41 minute(s) ago, # ^ |
          Vote: I like it 0 Vote: I do not like it

        just in general, you will find tons of comments complaining about a hard div2C or something.

        But, there are almost no comments complaining about how constraints were changed mid round...

        • »
          »
          »
          »
          »
          23 minutes ago, # ^ |
            Vote: I like it +1 Vote: I do not like it

          i think the reason no one complain about the constraint change in this round's G is because the constraint change does not affect the initial solution for the problem pre-change, and all the change did is probably made some coders mildly annoyed because they had written some edge cases for the problem before the change.

          i do agree tho that constraints change midway through contest can be fatal

          • »
            »
            »
            »
            »
            »
            3 minutes ago, # ^ |
              Vote: I like it +1 Vote: I do not like it

            You are right that the constraint change isnt the issue

            The issue was that the authors wrote the wrong solution, and thus my correct solution was marked as incorrect before rejudging with the changed test data.

            So it was me who was extra careful, while mostly everyone else wasnt

    • »
      »
      »
      19 minutes ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      Its probably because its a G, so many didnt even get to it. I personally got to it only after constraints changed, and only realised after contest that anything actually happened. Im not saying this justifies it or anything, just giving an explanation :D

  • »
    »
    29 minutes ago, # ^ |
      Vote: I like it +1 Vote: I do not like it

    Hi, first of all, I want to say sorry to you for this. For me, it is sad to look at all of this, because, I put the most afford in G among all tasts (I think because it has been changed little before contest).

    For me, two solutions (your and what we have done) seem like equally good. I mean, if you know how to solve this problem, you should know how to do with that tests. But if we would notice this test before contest, it would be put in the samples, since in other case there would be wa2 everywhere. But we cannot change samples during the contest. So, I think this decision was better in this case.

    One more time, sorry for inconvinience. We didn't want such think to happend.

    • »
      »
      »
      18 minutes ago, # ^ |
        Vote: I like it +1 Vote: I do not like it

      it was a great contest, and i found G really enjoyable even though i upsolved it 15 mins after the round, thank you very much!

»
85 minutes ago, # |
  Vote: I like it 0 Vote: I do not like it

Thank you for fast editorial

»
62 minutes ago, # |
  Vote: I like it 0 Vote: I do not like it

Hi I am a begginer and I really liked your effort on this round thank you for the answers so I can get the clues of coding

»
45 minutes ago, # |
  Vote: I like it 0 Vote: I do not like it

Very good problem H!

»
19 minutes ago, # |
  Vote: I like it 0 Vote: I do not like it

Could someone tell me ,for problem E , why this submission is giving wrong answer for test case 97 of test 2 . https://mirror.codeforces.com/contest/2008/submission/279256847

»
18 minutes ago, # |
  Vote: I like it 0 Vote: I do not like it

I solved problem E in O(nlog(26)) using two sets.

For even ns my solution is basically the same.

For odd ns, I brute forced the index of the character to delete. First I deleted the first character from the string and inserted frequencies of other letters on odd and even indexes in each of these sets. Then for other characters, I updated the set of frequencies by erasing, updating and inserting a frequency of character.

you can also check my code if you're interested: 279194144

»
12 minutes ago, # |
  Vote: I like it 0 Vote: I do not like it

very nice idea for problem H. also, the sentence "we need to find the smallest element which has at least $$$\big\lfloor \frac{n}{2} \big\rfloor$$$ elements in the array that is less or equal to it" in the editorial for H is kinda confusing since some people might interpret it as "find the smallest element $$$h$$$ which has at least $$$\big\lfloor \frac{n}{2} \big\rfloor$$$ elements in the array that is less or equal to $$$h$$$ including $$$h$$$".

my suggestion is to change it into "we need to find the smallest element such that it has at least $$$\big\lfloor \frac{n}{2} \big\rfloor$$$ other elements in the array that is less or equal to it" or smth along that line. also, i can see that you use translator (probably) to write this edi.