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

Автор awoo, история, 17 месяцев назад, По-русски

1766A - Суперкруглые числа

Идея: BledDest

Разбор
Решение (BledDest)

1766B - Notepad#

Идея: BledDest

Разбор
Решение (awoo)

1766C - Гамильтонова стена

Идея: BledDest

Разбор
Решение (awoo)

1766D - Удачные цепочки

Идея: BledDest

Разбор
Решение (adedalic)

1766E - Декомпозиция

Идея: BledDest

Разбор
Решение (BledDest)

1766F - MCF

Идея: BledDest

Разбор
Решение (BledDest)
  • Проголосовать: нравится
  • +77
  • Проголосовать: не нравится

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

ratttttttttttttttttttttttttttttttttttttttttttttttttttttting plz

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

When will the ratings update? :(

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

It is the first time that I will have a oringe name. I really want it could update rating as quickly as possible.plz

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

I didn't read B properly and thought that $$$n$$$ could take on values other than the length of the input. I thought I needed to implement a complicated LCP+Suffix Array method than ran in $$$O(n*log(n)^2)$$$ to greedily compute the minimum number of operations needed to produce the resulting string, which I wasn't able to do during the contest.

Here's my solution which actually computes the minimum number of operations: 185016918

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

In A why 184918763 got TLE?

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

    That's why you are grey.

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

    Because you are iterating from 1 to n in each case. So the time complexity would be O(t*n) which would give TLE. You have already calculated if each i is extremely round or not. Just construct a prefix sum array which would tell how many extremely round numbers are less than i. Then you can answer each case in O(1).

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

    Your algorothm takes n (n = the given integer) iterations of the loop for each test case. At worst, your algorithm will have to do $$$999 \ 999$$$ iterations of the loop for each test case. A test set can contain up to $$$10^4 = 10 \ 000$$$ test cases. Your algorithm might need to do $$$10 \ 000 \cdot 999 \ 999 = 9 \ 999 \ 990 \ 000 \approx 10 \ 000 \ 000 \ 000 = 10^{10}$$$ iterations of your loop. C++ can do around $$$10^8$$$ operations on average in one second. Each iteration of your loop contains 4 fast operations: i<=n, f[i]==1, ans++ and i++. Even though these are simple and fast operations, c++ can't execute that many of them in under 3 seconds.

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

      I mean what you meant is codeforces, or his pc doesn't have computation power to execute it. c++ is just a language

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

For D, we can consider only prime divisors of $$$y-x$$$ because to minimize the answer, if it's possible to get $$$\gcd(x,y) \neq 1$$$ for a certain composite $$$d$$$ s.t. $$$d|(y-x)$$$, it's definitely possible for some prime $$$p < d$$$ and we can reach multiples of $$$p$$$ at least as soon as we reach a multiple of $$$d$$$.

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

state transition graph for 1766E([i] represent for a sequence end with i)

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

    This state transition is sufficient enough to arrive at the intended solution.

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

Nice round. I think D and E are the best problems I've ever seen.

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

Video Editorial of Problem C : Hamiltonian Wall Link : https://youtu.be/p4-bUeGfs48

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

E is simply brilliant.

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

    It would have been more brilliant if the states have been around 10000000000000000000000000000000000000000000000000000000000000000 and transistions ended at russia and started at your brain

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

The complexity given for B is wrong. It is O(1). There are 26^2 possible unique 2-letter strings. Any string longer than 26^2+1 will have at least one repetition due to the Pigeonhole Principle.

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

    You have to read the string, so it is $$$O(n)$$$. And even if you read it character by character, in order to go to the next test case, you still have to read the whole string.

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

I still don't understand why we need all the prime divisors of each number in C. Don't we only need the smallest prime divisor to know the earliest point when the chain will stop?

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

    Yeah correct, knowing the smallest is sufficient

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

      No, take the example (4,19), y-x = 15 and the smallest prime factor is 3, however the smallest k that ensures gcd(4+k,19+k) = 3 is k = 2, but with a prime factor of 5, we find the smallest k ensuring gcd(4+k,19+k) = 5 is k = 1. That's why we run over all prime factors and take the minimum k for each.

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

        actually knowing the smallest is suffice because you can iterate x /= least[x] then update the answer, which is a bit faster. My solution during contest: 184938325

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

          Yeah I solved it that way too but I took the OP's question as "why can't you just use the smallest prime alone"

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

Решение задачи А за O(1): https://mirror.codeforces.com/contest/1766/submission/184938938

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

if anyone wants the O(1) solution for A, here it is :)

184929564

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

What will be the expected rating of the first 3 questions?

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

when will the rating be updated???

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

Why this submission passed problem 2? Surely it's complexity is O(n^2) Your text to link here...

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

    There are only 26^2 = 676 patterns of two successive characters.

    It means that this loop will end within at most approx.700*|s| times, and is enough fast to pass.

    This is called Pigeonhole principle.

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

      I think any string longer than 704 will always be YES, and I guess the string below might be the longest one that can be NO.

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

The contest which made me master! 139 is a happy number.

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

Problem- E:- Can anyone tell, which case they where missing while they where getting WA at test case 16.

expected: '1476747', found: '996573'

How to correct it.

Thanks in advance :)

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

The B solution is wrong: Try this testcase: - t=1 - string='abcdabef' - n=6, - the answer is yes according to solution but it's wrong becuase: - 4 operations for 'abcd', - then 5th operation for copying and appending 'ab' string, - then 6th and 7th operation for 'ef', - so number of operations exceed n.

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

Is the concept "smallest prime factor" (minD) a well-known thing?

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

the pair contribution dp thing is something i've really only seen in digit dp problems, interesting to see it works with subarrays as well :)

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

Why my solution of problem D gives TLE? 215848671

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

Can any one help me in understanding what this part of code do in the solution of 1766D — Lucky Chains

int r = INF;
	for (int p : getPrimes(d))
		r = min(r, ((x + p - 1) / p) * p);
	cout << r - x << '\n';