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

Автор feecIe6418, история, 6 лет назад, По-английски

Hello Codeforces!

gyh20 and I are glad to invite you to Codeforces Round 670 (Div. 2) which will start on Sep/12/2020 16:45 (Moscow time). Note the unusual start time of the round.

The contest will last for two hours, and you will have five tasks to solve. The tasks are prepared by me and gyh20. This round is rated for participants whose rating is not higher than 2099. You can see that my current rating is exactly 2099 :)

There might be an interactive problem. You can learn about them here.

We would like to thank:

We tried our best to make the statements short and clear, pretests strong and problems interesting. We hope you like the problems!

Score distribution will be announced shortly before the round.

Good luck and have fun!

Upd: Score distribution is 500-750-1250-1750-2500.

Upd: For problem reasons, the contest is delayed for 10 minutes. We are very sorry to keep you waiting, sorry again.

Upd: Score distribution is changed to 500-1000-1500-2000-2750.

Upd: The round is finished. We're really sorry for B being well-known (none of the testers knew the harder version of this problem in ABC173E). Still, congratulations to the winners!

Div1 (unofficial):

  1. WZYYN
  2. Geothermal
  3. kort0n
  4. neal
  5. kotatsugame

Div2:

  1. JSoap
  2. DemolitionLovers
  3. killyou
  4. gmh77
  5. SkyStar

Upd: Editorial is out here.

  • Проголосовать: нравится
  • +772
  • Проголосовать: не нравится

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

As a tester,I want some contribution!

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

As a coauthor,I am so glad to hold the contest, and i want you-know-what.

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

feecIe6418 Can you highlight the start time of the contest.

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

Really looking forward to the contest!I think it will be very good!

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

As a problem improver, have fun!

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

    What I improved is following:

    In the task E, there was one more constraint "It is guaranteed, that an integer $$$p \gt 1$$$ such that $$$x$$$ is divisible by $$$p^2$$$ does not exist. You want to find $$$x$$$."

    I noticed that we can erase this constraint. If you couldn't solve E, it's good that thinking this version first!

»
6 лет назад, скрыть # |
Rev. 3  
Проголосовать: нравится -118 Проголосовать: не нравится

Off Topic : What is the cutoff for candidate master.. 1800 ? or 1900 ?

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

Your rating is exactly 2099 but unfortunately the round is not rated for you.

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

feecIe6418, Will there be any subtasks? I really think having subtasks makes contest more interesting.

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

Every Round is rated for me, except div 1 :3

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

Are the authors middle school students?

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

Special thanks to csani for helping us with writing the editorials

Editorials are already written?

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

As a tester, I would recommend you to participate in this. The problems are really interesting. Good Luck and have fun.

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

That day is my birthday. It will be a memorable contest lmao :))

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

$$$Yoo$$$ now it's becoming trend of $$$make \,the\, statements \,short \,and \,clear$$$

»
6 лет назад, скрыть # |
Rev. 2  
Проголосовать: нравится +33 Проголосовать: не нравится
  • Round #$$$666$$$ contains $$$5$$$ problems for each division.
  • Round #$$$668$$$ contains $$$5$$$ problems for each division.
  • Round #$$$669$$$ contains $$$5$$$ problems.
  • Round #$$$670$$$ contains $$$5$$$ problems.

Is it a trend or...something else?

»
6 лет назад, скрыть # |
Rev. 4  
Проголосовать: нравится -8 Проголосовать: не нравится

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

486bie.jpg

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

I have a question for the authors. Do you know Jiangly? Are you friends?(Sorry. I now feel that this question is not so appropriate. Thank you very much for the author's answer.)

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

Excited to take part in my first contest!

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

I have known that the author is very excellent,bless all and hope everyone get higher rating.

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

After two years without competing here, it is time to come back! :)

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

Hope that the interactive one will be nice just like the one in the last contest...

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

Thank GOD for no scary pictures this time...

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

Great!! Problems with short and clear statement are really good. Hope this will be a good round.

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

Why do all the Div.2 rounds consist of 5 problems nowadays? Why not 6/7?

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

    How many times have you solved more than 3-4 questions lol?

    On a serious note, you and I can't even imagine the amount of work it goes into setting a problem and preparing the statements, test cases, etc. So, simply saying things is very easy, when you don't know what is going on behind the scenes

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

I hope it have strong pretest!

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

I don't want to FST any more.

So do you have the strong pretests?

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

This is gonna be my first ever contest. So excited about it. Not very experienced in Competitive Programmer but my journey starts from now. I hope this be a hell of a journey!

UPD : For those who Upvoted me and wished me luck, thank you so much! I think your wishes came true and i got Rank : 652 and Rating got +671

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

Is there any Chinese description

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

Happy Programmers' Day!!

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

What's Polygon?

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

Socre distribution <- typo

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

The comment is hidden because of too negative feedback, click here to view it

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

As far as I've seen, this is your first contest arrangement in CF. Best of luck to you too.

(Hope everything will be fine)

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

Interactive problem will be there or not ?

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

There might be an interactive problem.

I guess that codeforces is trying to make interactive problems a part of the contests, which according to me, is a good thing to do.

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

start the contest!! im feeling horny

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

Delayed by 10 min :(

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

Auto comment: topic has been updated by feecIe6418 (previous revision, new revision, compare).

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

Very sorry,something we didn't expect happened just now ,the contest is delayed by 10 minutes, hope there won't be another delay.

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

wish me good luck.

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

Delay it as much as you want and solve the problem PLEASE DON'T MAKE IT UNRATED due to those issues

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

delayforces again lol, but still great thanks for the preparation!

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

delay making me more anxious.

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

Score distribution changes.

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

Hoping for strong pretests!

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

How to solve D?

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

    Didn't passed system test yet but my solution idea is :-

    Hints:-

    ans is

    tot = a[0]+d where d = sigma( max( 0, a[i+1]-a[i] ) );

    ans = (tot+(tot>=0))/2;

    so only edges L and R in queries can change the value of d.

    I guess now you can figure out the solution

  • »
    »
    6 лет назад, скрыть # ^ |
    Rev. 3  
    Проголосовать: нравится +26 Проголосовать: не нравится

    My solution has not yet passed sys tests but here is how I solved it. Suppose we let initial value of non decreasing array be c so initial value of non increasing array will be a[1]-c.

    Now for each next element if is greater than previous value we can keep the value in non increasing array constant therefore the other array remains non decreasing. We can similarly keep the value in non decreasing array constant if the next element is less than the previous one.

    Therefore we get the final value of non decreasing array as c+(sum of all positive a[i]-a[i-1]). Now we just have to minimise max(a[1]-c, c+sum of +ve dif). We can see that it will be minimum if both elements are equal.

    After each query only 2 differences are changed at max so we can store values of each element by Fenwick Tree and recalculate the optimal c. Upd: passed sys tests.

  • »
    »
    6 лет назад, скрыть # ^ |
    Rev. 7  
    Проголосовать: нравится +4 Проголосовать: не нравится

    Observe that since $$$b_{i}$$$ is non-decreasing and $$$c_{i}$$$ is non-increasing, the max is just $$$max$$$$$$(c_{0}, b_{n - 1})$$$.

    We can notice that $$$b_{i} \gt b_{i - 1}$$$ will be required when $$$a_{i} \gt a_{i - 1}$$$ and $$$c_{i} \lt c_{i - 1}$$$ will be required when $$$a_{i} \lt a_{i - 1}$$$.

    Clearly $$$b_{0} + c_{0} = a_{0}$$$ is a required condition. Let $$$b_{0} = u$$$ and $$$c_{0} = v$$$.

    If $$$sum_{inc}$$$ is the sum of $$$a_{i} - a_{i - 1}$$$ whenever $$$a_{i} \gt a_{i - 1}$$$, $$$b_{n - 1}$$$ is clearly $$$u + sum_{inc}$$$. So we want to choose $$$u$$$ such that $$$max$$$($$$a_{0} - u$$$, $$$u + sum_{inc}$$$) is the minimum possible. This is clearly $$$\frac{a_{0} - sum_{inc}}{2}$$$ which gives an answer of $$$\lceil \frac{a_{0} + sum_{inc}}{2} \rceil$$$.

    As for the queries, we can notice that only the contributions from $$$a_{l} - a_{l - 1}$$$ and $$$a_{r + 1} - a_{r}$$$ to $$$sum_{inc}$$$ can change. Maybe there is some elegant observation that makes this easy to calculate, but without that also there is an easy way to figure out the change. Subtract the contribution of those two endpoints, update the range (standard lazy prop) and re-add the contribution of them.

    BE CAREFUL that you perform ceil correctly for negative values.

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

How to solve C

  1. See CF blog in recent actions
  2. Understand you can only have one or two centroids
  3. For one centroid print any edge twice
  4. For the second remove an edge going from the first centroid to any vertex except the second centroid(e) then make an edge going from the second centroid to e.

Easy AK!

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

How to solve E?

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

    I think ask for all prime numbers ( ~9600 ) and make some Inclusion–exclusion principle (ex if you have n = 6 ask for x=2 => s = {1,3,5,6} and for 3 you have to see that 6 is still there (because after the first operation just 1 element %3=0 had to remain in the set) ) .

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

    First we use the second operation to all primes < 1000, all the remaining numbers can either be a prime or $$$x$$$.

    We can query A 1 and check if $$$x$$$ is a prime.

    If $$$x$$$ is not a prime, we query every prime number $$$\leq n$$$, and obtain x by finding all prime divisors of $$$x$$$.

    If $$$x$$$ is a prime, we can do the following: delete S prime numbers, and query A 1 to see if $$$x$$$ is in the $$$S$$$ primes numbers you just deleted. When you find the $$$S$$$ numbers that contain $$$x$$$ you do $$$S$$$ extra queries to find $$$x$$$. Let the number of prime numbers be $$$N$$$, The number of operations is $$$N + S + N/S$$$, and we can set $$$S$$$ to $$$\sqrt n$$$

    code: https://mirror.codeforces.com/contest/1406/submission/92637463. It passed the pretests anyway.

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

    перебрать все простые делители до N начиная с таких, что их квадрат больше N, проверять можно по группам, например первые 100 такие делители с помощью функции 2 типа, и проверить есть ли среди данных 100 простых чисел нужное с помощью типа 1 и так далее по сто, а в последнем оставшиеся. Затем перебрать все меньшие простые делители и его степени. Например, k — простое, k * k < n, тогда если н делиться на к, с помощью бинпоиска найдем степень вхождения это числа.(iterate through all Prime divisors up to N starting with such that their square is greater than N, you can check by group, for example, the first 100 such divisors using a function of type 2, and check whether among the data 100 primes necessary using type 1, and so on one hundred, and in the last remaining. Then iterate over all the smaller Prime divisors and its powers. For example, k is a Prime, k * k < n, then if n is divisible by K, we use bin search to find the degree of occurrence of this number.)

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

Could anyone help me to find why my code for problem C is TLE.92617935

My solution is linear,as far as i know.

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

Great Contest!! B was really original problem!!

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

That's a nice contest!

Although I'm not able to solve E, I think the questions are very interesting and I really hope I can have the ability to make such greate problems :)

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

How to solve C? it seems it requires some observations, please anyone give hint.

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

    Basically there can atmax exist only 2 centroids and this happens when there exists an edge u-v such size of subtree of u is equal to size of subtree of v (in opposite directions) or basically s[u]=n-s[u].

    Now all you have to do is remove an edge from u and connect it to v and only 1 centroid will remain

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

How to solve idleness limit exceeded for problem E? Please help in this solution — https://mirror.codeforces.com/contest/1406/submission/92639473

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

Did anybody else did o(10^5) solution for b?

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

How to solve E? I got to finding out all prime factors (and their powers) except one. There can only be primes with power more than 1 until 317. Until 317, we check all powers of each primes < 10^5. For primes higher than this, it can be a factor with at most one power. We can iterate through all primes from here and apply operation B. We also keep track of how many more multiples must be remaining at this point. If it differs, we know that this must be a factor (and something else). If we continue iterating all of them, we get all the prime factors (and their power is 1 as explained) except the first prime number.

I couldn't figure out how to get this one. Can anyone solve the puzzle? :)

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

    I think we can group the primes greater than 317 into like groups of 100. After every 100 operations of the form "B p" we can do an "A 1" to check if the number of elements in the set has decreased by less than 100, in that case we know one of these primes is a factor of x and we go back over the group and perform an "A p" operation for each prime p in that group. I realized this in the last 5 minutes but didn't have time to fix my code :(

»
6 лет назад, скрыть # |
Rev. 2  
Проголосовать: нравится +16 Проголосовать: не нравится
»
6 лет назад, скрыть # |
Rev. 4  
Проголосовать: нравится 0 Проголосовать: не нравится

For D is this correct — $$$result = max(a_1 - x, tot + x)$$$ where $$$x = (a_1 - tot)/2$$$ and $$$tot = sum(a_i - a_{i-1}) $$$ $$$if$$$ $$$positive$$$ ?

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

    My idea that passed pretests was $$$sum = a_{1} + tot$$$ and $$$result =\frac{ (sum + (sum \ge 0)) }{2}$$$ (basically ceil division of $$$sum$$$ by $$$2$$$. What is $$$t$$$ in your notation?

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

    I didn't solve it in-contest but I think you can compute the minimum gain of sequence B and minimum decrease of sequence C by computing the sum of all rising edges (for B) and the sum of all falling edges (for C).

    The max of the two sequences is the start point of C or the end point of B. So we can shift up or down the entirety of B and C to find the point that equalizes those two points as closely as possible, which should be the optimum.

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

CopyPasteForces

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

Out of curiosity — is there some nice observation about the changes on both ends that allows D to be solved without using lazy prop for the range updates in the queries?

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

Can anyone tell what is wrong in this code. for B. Link:- https://mirror.codeforces.com/contest/1406/submission/92640232

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

Can anyone tell me what these numbers mean? I have never seen them before.

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

Am I correct in my logic for E?

I first find all primes upto n, then print each of them with a 'B'. After this round of operations only two integers, 1 and x if x != 1 should remain or only 1 if x = 1.

Then I print out each of the primes with 'A'. If I get 1, then i try its powers till i exceed n or get a 0. At each of these steps, if i get 1, I multiply the ans with x.

I think that this should be enough but this fails pretest 2. Can someone please point out why logic falters?

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

When E seems to be easy than D, but that constraint You can perform the following operations no more than 10000 times made it quite tough to solve.

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

For problem A, did the text change in between the contest? I think initially the problem was to split the set into two equal halves!

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

Thanks to KokiYmgch for "The way to find the centroids of a tree"

https://mirror.codeforces.com/blog/entry/57593

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

For Problem E I think we can group the primes greater than 317 into like groups of 100. After every 100 operations of the form "B p" we can do an "A 1" to check if the number of elements in the set has decreased by less than 100, in that case we know one of these primes is a factor of x and we go back over the group and perform an "A p" operation for each prime p in that group. I realized this in the last 5 minutes but didn't have time to fix my code :(

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

Is problem B solved by sorting the array and then using it like circular array by doubling its size by copying first half to 2nd half and use a sliding window of width 5 and find the max product? I Couldn't submit in time.

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

Please help me to figure it out why this solution 92602531 for problem B is giving the wrong answer for case 1 and exactly the same solution runs correctly on other IDE (CodeChef and my own local IDE)

I thought there may be issues with my current compiler version but after trying it with different versions, it stills gives wrong here but it runs correctly in other IDE's

»
6 лет назад, скрыть # |
 
Проголосовать: нравится -59 Проголосовать: не нравится
»
6 лет назад, скрыть # |
 
Проголосовать: нравится +16 Проголосовать: не нравится

E was cool! Thanks

But i am actually not understand why we need answer on type B query...

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

    How to solve it?

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

      There are abut 9600 primes <= n, and about 70 numbers <= sqrt(n).

      Let me name prime number which <= sqrt(n) as small and >sqrt(n) as big

      And actually there is 0 or 1 big number in X factorization.

      We can understand small primes in X factorization using about 200 queries (asking A queries about p, p*p, p*p*p, ...)

      And how to understand is there a big prime? We can arrange all big numbers on 100 groups of 100 numbers. Lets check every group separately using B queries and after checking it ask A(1) to understand was bg prime found or not. If it was found check this group again.

      It will be like 200+9550+200=9950 queries

      Sorry for my bad English ;(

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

Best channel for editorial of this contest . https://www.youtube.com/channel/UCBStHvqSDEF751f0CWd3-Pg/ Do view and subscribe

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

How to run interactor & solution for an interactive problem in terminal/cmd?

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

I tried solving B with multiset can any one tell me why am I facing TLE. Worst complexity is O(n * 2logN). Submission

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

For problem C — if there are two centroids then we disconnect the leaf of 1 centroid and connect it directly to the other centroid. How does this not works ?

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

My approach to problem E:

$$$Ans=p_1^{k_1}\cdot p_2^{k_2} \cdots$$$.

For $$$p \le \sqrt{n}$$$, just ask their exponents directly. This costs about $$$180$$$ queries.

For $$$p \ge \sqrt{n}$$$, there is at most one prime factor. So remove $$$\sqrt{cnt_{primes}}$$$ primes in one time and check if the number of remaining numbers is wrong. If wrong, the factor is in the last $$$\sqrt{cnt_{primes}}$$$ numbers you remove.

There are $$$cnt_{prime}+2\sqrt{cnt_{prime}}+41+66\times 2$$$ queries at most. The time complexity is $$$O(n \ln n)$$$. Since the system test isn't finished, I don't know if it's correct.

edit: passed system test.

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

make this round unrated as B problem's code can be easily found,here are the links-> https://www.geeksforgeeks.org/maximum-product-subsequence-size-k/ https://atcoder.jp/contests/abc173/tasks/abc173_e https://www.codechef.com/problems/MMPROD

all those who have copied these code or have taken the logic from there are at an edge ahead of those who are solving problem honestly

Unrate this contest

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

Is LONG_MIN not defined in codeforces?

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

am i the only one who printed "1 2\n1 2" if there is only one centroid in C?

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

Is it possible to solve prob/B with dp ? Thank you for your responses but is there a recurssive dp solution ?

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

https://mirror.codeforces.com/blog/entry/57593 By just applying this links code to tree C problem can be solved

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

    What's next after finding the centroids of the tree using the code in the tree? The problem isn't solved yet!

    Finding the centroids are just a helping tool and not the full solution

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

      If $$$N$$$ is odd, is it always the case that the answer is printing a random edge twice (unique centroid)? Can anyone help me in proving that or hacking my submission?

      I have tried to find a sub-tree of size exactly $$$N / 2$$$ if $$$N$$$ is even.

      My submission: 92627903

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

        Indeed if N is odd, there can be only 1 centroid. Thus printing a random edge twice is valid.

        Then finding a subtree of size N / 2 if N is even, is also correct. Since those are the only nodes that satisfy sz[node] >= N / 2 and N — sz[node] >= N / 2 -> node is a centroid.

        Congratulations! Your solution is correct!

        (I might be wrong though feel free to correct me)

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

      IMO the tricky part of the solution is to find the centroid as after finding centroids we can remove any subtree from one centroid and connect it to the another centroid

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

        And do you have proof of that? Does it always work?

        You may have found that as intuitive, but many others don't

        The problem tests you if you found that property, not testing you how to find centroids

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

    Yeah applying this code gives you AC but only "JUST" applying wont get you anywhere ,this is the basic difference between having a particular tool and knowing where and how to use it.

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

In problem C, how can we prove that there can at max 2 centroids? I took this as an assumption (based on observation) and fortunately it turned out be correct.

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

    This is my personal proof for this. Correct me if I'm wrong.

    Proof: assume that there's k > 2 centroids. Then, those k vertices should be connected by (k-1) edges (since they should form a tree). But because by Pigeonhole Principle, at least 1 vertex will certainly get 2 or more subtrees (from the other centroids). Then the centroid would be that vertex. Contradiction.

    Hence, the number of centroids should be at max 2.

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

So thanks for the nice constest feecIe6418, and now you may come up with the turorial.

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

I love problem D so much and thanks for this wonderful contest!

By the way,E is really hard...maybe I will try it later.

Difficulty gap: A<B<C<<D<<<<<E

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

Thanks for the cool problems! I've got video solutions to everything at the end of this if you're looking for them since the editorial isn't out yet :)

  • »
    »
    6 лет назад, скрыть # ^ |
     
    Проголосовать: нравится -22 Проголосовать: не нравится

    Thanks for your effort . Following things could be improved :

    1. In problem E's explanation , you have written "to make sure x is a big prime" . No x is an integer and may not be prime . 2.In problem E , you told we will take 1 extra query , what will be that extra query ? And how it will help knowing if prime is big/small or lies in the bucket .

    If you just explain that briefly , to be honest it's no better than editorial .

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

      I explained it pretty clearly I think. There are two cases. The first is the one in which x is a big prime. In that case you handle it with bucketing the primes. The other case is when x is not a big prime: it has at least one factor smaller than sqrt(n). In that case, you will see that there are more multiples of the big prime than there were suppose to be, so you can deduce that that prime is a factor of x when you see that.

      You can check which case you are in by querying "A 1" after the first sqrt(n) queries.

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

Where is the pre-prepared editorial ..
I need help on C,D.. can any one give me easy hnts of C or D please.

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

I solved B using DP using 3 parameters the index of the current element 'idx', remaining elements 'rem', and the sign of the product till index 'idx', if neg is 1 meaning '-' otherwise '+'.

It seems the complexity of the solution is O(n*5*2) but still TLE.

Here the link of the solution: https://mirror.codeforces.com/contest/1406/submission/92647209

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

The constraints given in B. Maximum Product are wrong. it doesnt work if you take t as int and n as int and a[i] as int. Gives overflow. whereas it should not give overflow according to given constraints in the question.

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

in C I think if tree has 2 centroid then they must have edge between them or they are adjacent...can anybody prove this wrong..

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

I liked the contest

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

    mmm, I liked the contest. Also, why do you say just math?

    • problem A was an easy ad-hoc problem.

    • problem B just needed very basic stuff of math, and then it just was Brute Force or even Dynamic Programming.

    • problem C wasn't math. It was graph theory.

    • problem D maybe was math, but it could be solved with data Structures.

    • problem E was math, and it could be solved by using some nice ideas like SQRT Decomposition.

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

Why I got 5 times WA for problem A and got AC with same code afterwards without changing anything ?

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

    if(mp[x]>1)

    if(mp[x]>1 and mp[x]%2==0)

    are they same?

    update: your mex function is not correct, for example in the first case a.size() is only 3 but you'll visit a[3], so you may get a wrong answer sometimes.

    you can change it to

    for (ll i = 0; i < a.size(); i++) { if (a[i] != i) return i; } return a.size();

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

To not keep you waiting, the ratings updated preliminarily. In a few hours, I will remove cheaters and update the ratings again!

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

In B Just because of 3*10^3 I was not able to solve. I have assumed min as -1e16 instead of -1e19. I think the most important thing before solving a problem is reading it carefully.

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

Editorial:https://codeforces.ml/blog/entry/82560

tianbu has already gone to bed and I don't have the access. So wait until tomorrow to see the Editorial on the announcement.

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

can anyone tell me why my code is givin runtime error on test case 3 in python.

https://mirror.codeforces.com/contest/1406/submission/92659527

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

Wasn't the editorial already written ? xD

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

Why my submissions are skipped

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

In problem 1406C, the center of mass of a tree has an important property that a tree has at most two centers of mass, and the two centers of mass are connected.

According to this property, when solving the problem of 1406C, if the data given has only one center of gravity, it can be solved only by deleting and adding the same edge.

If the data given has two centers of mass, we break a subtree of one center of mass and connect it to the other center of mass, so that the other center of mass becomes the only center of mass.

For finding the center of gravity of the tree, I used one of the templates in CSDN (a Blog from China), This blog post was published on August 19, 2016.I used most of the code in question 2 and only changed it in the final output.

link: https://blog.csdn.net/qq_35866453/article/details/52254234?utm_source=app

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

In my opinion, code style of the editorial is awful.sorry. By the way, nice problems.

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

1406B - Maximum Product is basically the extension of this problem : https://www.geeksforgeeks.org/find-maximum-product-of-a-triplet-in-array/ logic is pretty much the same

1406C - Link Cut Centroids seems to be very well known, lol, I spent 30 mins in proving that there can be atmost 2 centroids in a tree, had I resorted to googling "centroid of a tree" I may have got it immediately, you could have atleast changed the name "centroid" to some random thing like "good vertex"

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

Could anybody explain why is my solution of B is wrong? If there are enough, we can take even amount of negative elements(most minimum) and 5 — cnt_negative of positive. this is my code https://mirror.codeforces.com/contest/1406/submission/92591345 thank you.