ne_justlm's blog

By ne_justlm, 19 months ago, translation, In English

Thanks for participating in the most isekai NyaForces contest!

We honestly strived to make good tasks.

2072A - New World, New Me, New Array

Idea: ne_justlm

Tutorial
Solution
Rate the problem

2072B - Having Been a Treasurer in the Past, I Help Goblins Deceive

Idea: ne_justlm

Tutorial
Solution
Rate the problem

2072C - Creating Keys for StORages Has Become My Main Skill

Idea: ne_justlm, IceHydra

Tutorial
Solution
Rate the problem

2072D - For Wizards, the Exam Is Easy, but I Couldn't Handle It

Idea: ne_justlm

Tutorial
Solution
Rate the problem

2072E - Do You Love Your Hero and His Two-Hit Multi-Target Attacks?

Idea: ne_justlm

Tutorial
Solution
Rate the problem

2072F - Goodbye, Banker Life

Idea: itz_pabloo

Tutorial
Solution
Rate the problem

2072G - I've Been Flipping Numbers for 300 Years and Calculated the Sum

Idea: ne_justlm, IceHydra

Tutorial
Solution
Rate the problem
  • Vote: I like it
  • +67
  • Vote: I do not like it

| Write comment?
»
19 months ago, hide # |
 
Vote: I like it +11 Vote: I do not like it

F was so good!

Apart from the Pascal's triangle solution, You can do it by recursion and I learned that the self-similar repeating fractal pattern formed by F is called a Sierpinski's triangle!

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

nice

»
19 months ago, hide # |
Rev. 2  
Vote: I like it +4 Vote: I do not like it

Thanks to the authors for a good round

»
19 months ago, hide # |
 
Vote: I like it +3 Vote: I do not like it

constructive contest

»
19 months ago, hide # |
 
Vote: I like it +13 Vote: I do not like it

For the F, if we use Lucas' Theorem, we can actually deduce that $$$\binom{n}{k}\mod 2$$$ is 1 only if $$$k$$$ in binary is a submask of $$$n$$$, in other words if $$$k$$$&$$$n$$$ equals $$$k$$$

With this there's an elegant two-line solution in $$$O(n)$$$:

int a,b;cin>>a>>b;a--;
for(int i = 0;i<=a;i++) cout << (int)((a&i)==i)*b << ' ';
  • »
    »
    19 months ago, hide # ^ |
     
    Vote: I like it +3 Vote: I do not like it

    that is our model solution, but we thought that power of 2 solution is easier to understand.

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

    hello there, can you please explain what submask means

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

      If k is a submask of n, then every bit that is 1 in k is also 1 in n. for example 0010001 is a submask of 1010011, because the only bits that are 1 in the first number (3rd and 7th), are also 1 in the second number.

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

    amazing solution man, had a small doubt, in lucas theorem when we convert the numbers to different bases, do the bases have to be the same prime number we are taking % with at the end ?

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

some how deepseek solved G on first try

»
19 months ago, hide # |
Rev. 2  
Vote: I like it +28 Vote: I do not like it

ne_justlm In fact, the first part of the problem G is not $$$O(\sqrt{n} \log n)$$$. The reason is that the total time is equal to $$$\sum\limits_{i=2}^{\sqrt{n}} \frac{\ln n}{\ln i}$$$, and since the logarithmic integration yields a complexity of $$$\int\limits_{2}^\sqrt{n} \frac{1}{\ln x} dx=O(\frac{\sqrt n}{\ln n})$$$ for the latter part, the total complexity is $$$O(\sqrt{n})$$$

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

In the problem F, you said that we will build each the numbers in the n-th rows bit by bit, but why in the solution you just multiply it with the odd condition. I understand that when we have odd condition of power of 2 then the bit i-th at which Ki is set also must be set for the number, but do multiplication hold this property? Or how can I relate multiplication with xor property, thank.

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

    multiplication works because condition will be either $$$0$$$ or $$$1$$$, so multiplying by it is just the same as set all set bits from $$$k$$$ to $$$1$$$.

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

For the F , I tried to print out the triangle to find the pattern, and finally I found that they meet this pattern, can someone help prove it?

        for(int i =0;i < n;i++)
        {
            if((i|(n-1))==n-1)
                cout<<k<<' ';
            else
                cout<<0<<' ';
            cout<<endl;
        }
»
19 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Problem F: Not too different from the official solution, but I calculated the parity of binomials using the following formula:

$$$\begin{align*} \binom{n}{0} &= 1 \\ \binom{n}{r} &= \binom{n}{r-1} \cdot \frac{n - r + 1}{r} \end{align*}$$$

Then you can sequentially count the numbers of factor $$$2$$$ in the denominator and the numerator for each $$$r$$$.

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

    "count the numbers of factor 2 in the denominator and the numerator"

    what do you mean by this ?

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

      Let's say you can denote $$$\displaystyle \binom{n}{r}$$$ as a fraction $$$\displaystyle \frac{p}{q}$$$ (note this value is always an integer). Let's extract the factors of $$$2$$$ from $$$p$$$ and $$$q$$$:

      $$$\begin{align*} p &= 2^s \cdot p^\prime, \\ q &= 2^t \cdot q^\prime. \end{align*}$$$

      Where $$$s \ge t$$$ since $$$q$$$ divides $$$p$$$. Then the following holds:

      $$$\begin{align*} \frac{p}{q} \ \text{is even} \iff s \gt t. \end{align*}$$$

      Therefore, to find the parity of $$$\displaystyle \binom{n}{0}, \binom{n}{1}, \ldots, \binom{n}{n}$$$, you only need to count the number of factor $$$2$$$ s that appear in the denominators and the numerators in those values, instead of calculating those values in full. And this can be done sequentially, from $$$\displaystyle \binom{n}{0}$$$ to $$$\displaystyle \binom{n}{n}$$$, using the formula I wrote in the post above.

»
19 months ago, hide # |
Rev. 2  
Vote: I like it 0 Vote: I do not like it

How tf did newbies and pupils know lucas theorem for F ???? Anyways F is a beautiful problem.

»
19 months ago, hide # |
Rev. 2  
Vote: I like it +1 Vote: I do not like it

Seems like proof for E is not complete as "For k <= 446, the algorithm places no more than 43 sticks", how do we get this 43 sticks, do you proceed the same proof with upper bound is 446 instead of 10^5 and repeat for the next upper bound until reach 0? Do we have any formal proof, thank you!

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

Can anyone explain me why (n^2) solution worked in problem D? Because timeComplexity is (testcases*n*n) => (10^4 * 10^3 * 10^3) => 10^10 which is greater than 10^8, then why it not giving tle

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

    There is a condition on the input saying that sum of $$$n^2$$$ over all n in the testcase is bounded to $$$4*10^6$$$, so it is only $$$2*10^3 * 10^4 = 2*10^7$$$ operations, which fits the time limit.

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

      total complexity is $$$\mathcal{O}(\sum\limits_{i = 1}^{t} n_i^2)$$$ which is already bounded to $$$4 \cdot 10^6$$$. that would be the total number of operations

»
19 months ago, hide # |
Rev. 3  
Vote: I like it 0 Vote: I do not like it
»
19 months ago, hide # |
Rev. 3  
Vote: I like it 0 Vote: I do not like it

In the third case where $$$\log_p{n} \le \log_{\sqrt{n}}{n}$$$ , in the case where they are equal wouldn't the number of digits be $$$\log_p{n} + 1 = 3?$$$

»
19 months ago, hide # |
 
Vote: I like it +1 Vote: I do not like it

kinda surprised this submission for E didnt TLE. i guess recursion is not so bad

»
17 months ago, hide # |
Rev. 2  
Vote: I like it 0 Vote: I do not like it

I wasn't expecting D to be brute force of the nested loop type

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

I think F can be solved by Lucas theory.Here my solution. ~~~~~ int n, k; cin >> n >> k; n -- ; for (int i = 0; i <= n; i ++ ) { cout << ((i & (n — i)) == 0 ? k : 0) << " \n"[i == n]; } ~~~~~

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

sooooo many math :(