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

Автор cry, 18 месяцев назад, По-английски

2037A - Twice

Problem Credits: cry
Analysis: cry

Solution
Code (Python)

2037B - Intercepted Inputs

Problem Credits: cry
Analysis: chromate00

Are you a python user and failing test 4?
Solution
Code (Python)

2037C - Superultra's Favorite Permutation

Problem Credits: sum
Analysis: chromate00

Solution
Code (Python)

2037D - Sharky Surfing

Problem Credits: cry
Analysis: chromate00

Solution
Code (Python)

2037E - Kachina's Favorite Binary String

Problem Credits: Proof_by_QED
Analysis: Intellegent

Solution
Code (Python)

2037F - Ardent Flames

Problem Credits: Proof_by_QED
Analysis: Proof_by_QED

Solution
Code (Python)

2037G - Natlan Exploring

Problem Credits: Proof_by_QED
Analysis: Proof_by_QED

Solution
Code (Python)
Разбор задач Codeforces Round 988 (Div. 3)
  • Проголосовать: нравится
  • +128
  • Проголосовать: не нравится

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

nice fast editorial

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

damn quick editorial

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

Very Nice contest. :)

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

fast tutorial

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

Damn! Ultra Fast editorial Great Contest. Very good problems, Thanks!

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

мой код на b это перебор(i,j) пока не найду i*j==n-2,заваливает на 2 тесте почему

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

    Оцени сложность твоего алгоритма, дело в том что перебор двух значений из n имеет сложность O(n^2), что не подходит для n <= 2 * 1e5. Обычно процессор способен выполнять от 1e7 до 1e8 операций за секунду, тогда за 1 секунду таких входных данных нужно будет сделать 4e+10 операций что не подходит под ограничения по времени.

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

could anyone help me to figure out what is wrong here:292060911

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

yotta fast edito'

Thankkyou

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

Hi everyone, I apologize for the statement for D being unavailable for ~15 minutes during the round. It turns out I misspelled \textbf which caused the PDF to not generate. :(

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

very cool round, thank u.

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

I liked this contest, especially C exercise was interesting and pretty quirky at first :D Hope to see more div3 contests in the future

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

Can someone take a look at my implementation? (since below is my thinking for E which matches the tutorial exactly)

IMPOSSIBLE if and only if there exists no "01" substring, which is equal to querying the entire string and getting an answer of 0.

Otherwise, there is some "01", and we start querying all the prefixes [1, 2], [1, 3] ... [1, n]. Suppose the first one to give a non-zero answer is [1, i]. Let that answer be R. Then, since all prefixes before [1, i] gave 0 as an answer, the string over [0, i-1] is i-1-R 1's followed by R 0's. Also s[i] must be 1. To determine the suffix s[i+1, n], we query over the prefixes still [1, i+1], [1, i+2] ... [1, n], and, at each query, if the answer increases from the previous one, we have a 1 there, otherwise it is 0 there. In total, we take exactly 1 query for each char in s[2, n], meaning we require n-1 queries.

Implementation: https://mirror.codeforces.com/contest/2037/submission/292068546 (skip to very bottom, there is a bunch of template stuff at top)

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

Thanks for the contest, I was glad to participate) Thanks for explaining task G, I was very hesitant when I sent it and got a time limit exceeded on the 5th test

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

D felt like it would be hard problem at first but once u start solving it I found it easier than C

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

I was waaay off for D. i was thinking graphs. Thanks for the learning.

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

As a Pythonist participant, thanks for covering test 4 on Problem B that gives TLE verdict with dictionaries. I too got this verdict: Submission 291964656 Then, using set for tracking a prior occurrence worked on Submission 291974200 , instead of having to rely on the suggested collections.Counter().

Will have to see if this get hacked or failed in any of the main test.

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

非常好的题目,使我大脑旋转:D

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

Help me with this please: 292083026

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

    You need to continue processing hurdles until the left bound of the current hurdle surpasses current power-up.

    For your code, consider:

    1
    4 2 100
    5 5
    7 7
    9 9
    11 20
    2 1
    10 20
    

    which your code gives $$$-1$$$ but the answer is $$$2$$$.

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

      Please review my answer too : 292104008 , it also gives output -1 to the above testcase that you have provided and I have run my loop on hurdles not powerups, but I am unable to understand why the answer should be 2 for this testcase and not -1 because after the first hurdle {5 5} the power left should be zero so how will we reach to 10 and get +20 in power.

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

How to implement the Inclusion-Exclusion in G?

I knew about the principle and just did a bunch of for loops which at least look kinda cool :D 292061306 but I see others used other method.

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

i think it would be better to have G1 with lower constraint on $$$a_i \lt = 10^3$$$ to allow
$$$O(n*max(d(a_i)) ^ 2)$$$ solution as there are max 32 factors up to 1000, but anyways nice problems.
Thanks for the contest!

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

I am unable to understand why am i getting idleness time limit exceeded. — https://mirror.codeforces.com/contest/2037/submission/292077028. Please someone help.

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

Can someone suggest some binary search problems like F (same or little higher difficulty) please.

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

Hi I have two doubts.

First, why in problem B, using dictionaries in Python give TLE, but AC in C++?

Second, what is wrong in my code for problem E? https://mirror.codeforces.com/contest/2037/submission/292049495

I query (1, i) for i from 1 to n, find the first point where this value is non zero, and if this value increases fill in 1, else 0.

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

Can someone help me with this solution for D. 292088654

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

292093110

can someone pls see why this gives a wrong ans and what do I need to change ?

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

What's wrong with my solution for D? it gives tle(test-2). 292076200

»
18 месяцев назад, скрыть # |
Rev. 3  
Проголосовать: нравится +12 Проголосовать: не нравится

can somebody explain tourist code for problem G ? whats the mob array ?? whats the intuition behind the solution ?

291975854

or just simply explain whats the mobius function solution

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

    You can see the mobius function as the coefficients of the inclusive-exclusive solution

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

    Mobius function $$$\mu(n) = (-1)^k \cdot [\alpha_1=\alpha_2=\dots=\alpha_k=1]$$$ where $$$n=\prod\limits_{i=1}^k p_i^{\alpha_i}$$$.

    Useful property of Mobius function is that $$$\sum\limits_{d|n}\mu(d)=[n=1]$$$.

    Consider $$$\texttt{dp}[i]$$$ is the number of paths from $$$1$$$ up to $$$i$$$ and $$$\texttt{sum}[i][x]=\sum\limits_{j=1}^{i}\texttt{dp}_j\cdot [a_j=x]$$$.

    We may calculate $$$\texttt{dp}[i]$$$ as $$$\sum\limits_{j=1}^{i-1}\texttt{dp}_j-\sum\limits_{x=1}^{10^6}\texttt{sum}[i-1][x]\cdot [\gcd(x, a_i)=1]$$$. Let us apply the property of Mobius function for $$$[\gcd(x, a_i)=1]$$$. So that:

    $$$ \begin{array}{rl} \texttt{dp[i]} &= \sum\limits_{j=1}^{i-1} \texttt{dp[j]} - \sum\limits_{x=1}^{10^6} \texttt{sum}[i-1][x] \cdot [\gcd(x, a_i) = 1] \\ &= \sum\limits_{j=1}^{i-1} \texttt{dp[j]}-\sum\limits_{x=1}^{10^6} \texttt{sum}[i-1][x] \sum\limits_{d|\gcd(x, a_i)}\mu(d) \\ &=\sum\limits_{j=1}^{i-1} \texttt{dp[j]}-\sum\limits_{x=1}^{10^6} \texttt{sum}[i-1][x] \sum\limits_{d=1}^{10^6}[d|x]\cdot [d|a_i]\cdot \mu(d) \\ &=\sum\limits_{j=1}^{i-1} \texttt{dp[j]}-\sum\limits_{d=1}^{10^6}[d|a_i]\cdot \mu(d)\sum\limits_{x=1}^{10^6}[d|x]\cdot \texttt{sum}[i-1][x] \end{array} $$$

    For each $$$d$$$ you may maintain $$$\sum\limits_{x=1}^{10^6}[d|x]\cdot \texttt{sum}[i-1][x]$$$ and $$$d$$$ is the divisor of $$$a_i$$$ what makes it possible to compute $$$\texttt{dp}[i]$$$ in $$$\mathcal{O}(\sqrt{a_i})$$$.

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

I loved problem F, any problems like it please? :)

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

Using Counter still failed me in test case 4 for B (Or maybe there is a mistake in my implementation)

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

cry would be blessed if you also post the C++ code rather than just the 3 lines of the explanation in which you think everyone should understand how to solve the problem. Not everyone is a genius like you.

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

292066305 292064554 gpt guy solve g in 3 minutes

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

can we solve D problem using dp approach,with two cases only selecting a particular power or ignoring it

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

One easy way of preventing tle with sets in Python for B is to just move all the factors of k-2 into another map or set and do the same thing.

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

Hey guys, I don't know why my binary search solution fails. If you could help me with this that would amazin ^-^ thanksss

https://mirror.codeforces.com/contest/2037/submission/292111215

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

Nice contest, as expected from cry! Btw in problem E, were the constraints on $$$n$$$ reduced from $$$10^5$$$ to $$$10^4$$$? I used 32-bit integer during the contest and realized later on that my solution could get hacked...

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

    In fact, in testing, several testers got WA verdict with n<=10^5 because of overflow. Since its an interactive problem and the query limit is the hard part of the problem (as opposed to the time limit) we decided just to make n<=10^4 so nobody can overflow.

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

Thanks for the fast editorial.

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

Why is there a runtime Error for this submission?

https://mirror.codeforces.com/contest/2037/submission/292195133

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

damn, fast tutorial! nice contest

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

Will anyone explain how to do G with mobius inversion?

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

In the D Question, I was confused that if the jump power is used for particular jump then same cannot be used by it again for eg. jump_power = {1,3,5}, hurdle= {-6, -6} ,then I thought the answer would be -1, since the 5, 3 would be used for first jump and it cannot be reused later. sorry, but can some one please help me find which part of the sentence indicated that we can reuse it twice.thank you

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

    "When she is at position x with a jump power of k, she can jump to any integer position in the interval [x,x+k]."

    It is clear that there is not a limit which stop Mualani jumping twice with the same distance.

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

I wonder why G < F? I think the solution of greedy is easy to come out.

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

Can anyone explain why this is true for G:

Note that we don't actually care what the greatest common factor is, since the only requirement is that the greatest common factor is not 1. This also means that repeat appearances of the same prime number in the factorization of ai doesn't matter at all — we can assume each prime factor occurs exactly once.

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

Let's first add the count values from all prime factors, then subtract the count values from all factors with two prime factors, then add the count values from all factors with three prime factors, and so on. It can be seen that actually, the value is only counted one time now.

Can someone explain why this works?

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

For E,

I tried to make the string from left to right (? i n ) ,and in between if a 0 is encountered the remaining following sequence has to be (1111...1000...0)

For the input 2 01 its getting passed in test case 2 but when the same input comes in test case 3 its getting wrong answer!

Could someone please help me out!

Submission: 293642176

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

in problem D: testcase 1:

2 5 50 7 14 30 40 2 2 3 1 3 5 18 2 22 32

after taking 4th power-up my total power is 11, but to jump the 2nd hurdle I need a power-up of atleast 12 right? Why is the answer 4 then? shouldn't it be 5?