viking_34's blog

By viking_34, history, 10 months ago, In English
  • Vote: I like it
  • +3
  • Vote: I do not like it

»
10 months ago, # |
  Vote: I like it +10 Vote: I do not like it

https://codeforces.com/problemset/problem/1600/F is a very easy 2300 problem.

Solution summary
  • »
    »
    10 months ago, # ^ |
      Vote: I like it +14 Vote: I do not like it

    Thank You so much you are very kind :)

  • »
    »
    10 months ago, # ^ |
      Vote: I like it +2 Vote: I do not like it

    Better determinstic solution : find the corresponding ramsey number (~45) so n = min(n, 50) will solve the problem

    • »
      »
      »
      10 months ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      Hi Sir , I'm big fan of you , Congrats for reaching Grand master.

»
10 months ago, # |
  Vote: I like it +21 Vote: I do not like it

10D — Pretty obvious dynamic programming solution for 2800.

896E — Brute force approach works.

911G — Brute force approach works.

484E — Brute force approach works.

580E — Brute force approach works.

914F — Bitset solution works.

3D — Not a difficult greedy problem.

840D — Mo + random approach works.

755F — Knapsack solution with a famous trick.

Maybe there are solutions that respond to the rating, but there exist solutions that make the problem much easier, too.

  • »
    »
    10 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Thank You for the effort , it will be helpful for the community.

  • »
    »
    10 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Add this to the list 1838E - Count Supersequences, I found it easy.

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

      Sure sir !

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

        Just saw you had that there already. Thanks for acknowledging regardless.
        P.S. — Just realized, you might have added it after my suggestion, at-least it was useful then.

        • »
          »
          »
          »
          »
          10 months ago, # ^ |
            Vote: I like it 0 Vote: I do not like it

          Can you paste your code here and expalin it please ,I am not able to understand the editorial i tried a lot

          • »
            »
            »
            »
            »
            »
            10 months ago, # ^ |
              Vote: I like it 0 Vote: I do not like it

            I too did not get it

          • »
            »
            »
            »
            »
            »
            10 months ago, # ^ |
            Rev. 4   Vote: I like it 0 Vote: I do not like it

            Instead of counting the number of arrays of length $$$m$$$ which have $$$a$$$ as a sub-sequence.
            We will count the number of arrays which DO NOT have $$$a$$$ as their sub-sequence (read the last paragraph before the "Note" to understand why this cannot be done to find the answer more directly) and subtract that from the total number of arrays (of length $$$m$$$).
            There are a total of $$$k^m$$$ arrays of length $$$m$$$ (since each element can be anything from $$$[1,k]$$$).

            To find the number of sequences which don't have $$$a$$$ as their subsequence.
            We can go ahead and count the number of arrays $$$b$$$ which have prefix of $$$a$$$ till length $$$i$$$ (and sum up for all $$$i$$$ in $$$0$$$ to $$$n-1$$$).
            To do this we shall choose $$$i$$$ spots out of $$$m$$$ for placing first $$$i$$$ elements of $$$a$$$.
            To help with understanding, say the $$$i$$$ spots are $$$p_1$$$, $$$p_2$$$$$$...$$$$$$p_i$$$ (in increasing order).
            Till I reach $$$p_1$$$, I will not place any element equal to $$$a_1$$$, leaving only $$$k-1$$$ choices for each spot. Once on $$$p_1$$$, I will assign it the value $$$a_1$$$ in $$$1$$$ way. then proceed to not assign $$$a_2$$$ to any element till I reach $$$p_2$$$ (in $$$k-1$$$ ways per spot) and so on.
            The number of ways to choose are $$${m}\choose{i}$$$ and the ways to assign values for all such selections ($$$m-i$$$ in total) are $$$(k-1)^{m-i}$$$
            we are to find:-

            $$$k^m - \sum_{i=0}^{n-1}\binom{m}{i}.(k-1)^{m-i}$$$

            One can use inverse modulo ideas and the fact that $$$\binom{n}{r} = \frac{n-r+1}{r}.\binom{n}{r-1}$$$

            Solution


            Why not directly do it? (the note before the "Note")
            If you tried to find the arrays such that $$$a$$$ is a subsequence directly. You might want to choose $$$n$$$ spots out of $$$m$$$. but say the largest chosen element is $$$p_n$$$. now for all indexes in $$$b$$$ greater than $$$p_n$$$ (the array we are constructing) you can place any number out of those $$$k$$$. so the power of $$$k$$$ is heavily dependent on $$$p_n$$$ (there will be some $$$(k-1)$$$ terms too) which is not easy to deal with (we are choosing all sorts of elements, so, keeping track of the highest element and computing based on it isn't easy!)

            Note — I am not familiar with writing using LaTeX or anything, neither do I know how to align stuff here.
            Inconvenience is regretted.

        • »
          »
          »
          »
          »
          10 months ago, # ^ |
            Vote: I like it 0 Vote: I do not like it

          Yes , I have added it after your suggestion.

  • »
    »
    10 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    For problem 896E, maybe at the time of your submission it has weaker testcases, now it's showing TLE for brute force.

»
10 months ago, # |
  Vote: I like it 0 Vote: I do not like it
»
10 months ago, # |
  Vote: I like it 0 Vote: I do not like it

problems in difficulty range 1500-2000 are better since many people try to solve them.

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

https://codeforces.com/contest/1255/problem/D

No way this can be a div2 D and 1700 rated.

Idea