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

Автор satyam343, 4 года назад, По-английски

Hello, Codeforces!

amurto and I are glad to invite everyone to participate in Codeforces Round 838 (Div. 2), which will be held on Dec/15/2022 17:35 (Moscow time).

This Round will be rated for participants with rating strictly lower than 2100. Participants from the first division are also welcomed to take part in the competition but it will be unrated for them.

You will be given 7 problems and 2 hours and 30 minutes to solve them. One of the problems will be interactive. Make sure to read this blog and familiarize yourself with these types of problems before the round!

We would like to thank:

Score distribution is 500 — 1000 — 1750 — 2000 — 2500 — 2750 — 3500.

UPD1: Congratulations to the winners!

Overall:

Rated:

UPD2: Editorial is out.

We are looking forward to your participation!

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

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

Really awesome problems that I enjoyed testing very much. Highly recommended to participate (and up-solve :P)

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

As a tester, this is truly one of the rounds of all time.

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

As a tester master, I am the master tester. First round I tested, orz problems!!

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

Cool problems, I recommend taking part.

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

As a tester, Good luck to everyone who will participate

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

As a tester, I can assure you all will have fun in solving problems.

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

As a tester, I have enjoyed testing this problem set and all of the problems are really high quality

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

As a tester, I hope you'll enjoy the problems as much as I did! Yet another well-coordinated round by errorgorn :)

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

Please participate

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

As a tester, I highly recommend reading all the problems.

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

blog of #838 posted and there's no editorial for #837

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

As a tester, I didn't really tested the problems

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

As a tester, the round is awesome!

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

I see more comments from testers than from others, so I am also adding mine to increase the count XD.

PS: Problems are really good and one can look at stack's previous round to see his problem quality.

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

As a discusser of problems while proposal was in review and a tester, please let me participate

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

As a tester, so huge number of the testers...

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

As a tester, I really enjoyed testing this round. I solved some of the most enjoyable problems yet!

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

As a participant, I haven't tested the round yet. Really awesome problems that I enjoyed. I recommend this round for everyone.

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

As a participant its scary to have so many testers, I hope everyone may achieve Δ ≥ 0 :)

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

As a non-tester I can assure the problems are of high quality.

Source:- Trust me bro.

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

As a tester and an ex-tester, my assertion still holds true.

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

I think it will be interesting to solve this contest

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

As a tester, it’s a(Good) round ^_’

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

hope to gain more rating which i have lost in previous two contest.

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

As a nothing, this is truly one of the best contests.

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

why rating of previous contest is not updated yet??

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

I have never seen this many testers in any div2 contest.

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

Will the rating of educational #139 be updated before #838 starts? If not, rating of educational #139 will be updated based on the rating after #838…

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

Stack and Amurto Round. 🛐
Very excited for this contest.

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

When ratings will change?

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

When ratings will change?

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

After a long time. Best of luck Everyone.

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

RETURN MY RATTTTIIIINNGGGGG

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

When will the Ratings change for this round?

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

2 recent contests, someone can do this Meme

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

There is a list of allowed languages in the announcement Email:

C/C++, Pascal, Perl, Java, C#, Python (2 и 3), Ruby, PHP, Haskell, Scala, OCaml, Go, D, JavaScript and Kotlin.

I don't understand why do you limit the programming languages contestants can use? E.g. why can't I use Rust?

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

Is Perpetually_Purple suffering from success because now he is not "Perpetually_Purple"?

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

Argentina vs France suiii

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

oh no , 1750 points for problem c

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

Hi, I'm new to programming so was wondering, when the contest means it will start at 8:35 AM, does that mean we have to start coding at 8:35? Or can we start anytime after that?

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

    This game is from 8; 35 to 10:35,You can compete at any time during the two hours of the competition, but I suggest you enter at the beginning of the competition, otherwise your competition ranking may be lowered a lot.

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

All the best everyone

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

Good luck to everyone!

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

I think the interactive problem is C

**Do u agree that ?** 
»
4 года назад, скрыть # |
 
Проголосовать: нравится +4 Проголосовать: не нравится

Hey, Can anyone help me? I am a starter in cp, which div is suitable for me?

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

    The higher the Div number, the easier, so Div 4 is the most suitable for a newbie. However, this doesn't mean you should only do Div 4 contests. I encourage you to try ALL contests, but just keep your expectations realistic.

    If you're at a point where you cannot solve even the first problem in Div2 during the contest, try to aim to solve at least the first problem. If you're at a point where you can only solve one problem in Div2 during the contest, then try to aim to solve two problems, or at least try to solve the first problem a little faster and/or with fewer failed attempts. And so on.

    As long as you keep your expectations in check, you should be able to benefit from every contest, as long as you utilize them effectively as a learning experience instead of only trying to hope for a miraculously high ranking.

    But if you have time management concerns, e.g., you can only afford to put aside time for one contest in the next few days due to being busy with other work, then you should probably just stick with the easier contests for now, i.e. join the Div3 in a few days instead.

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

    Div2,3,4 is suitable for you. Participate on those divisions contest regularly.

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

Hope to get to cyan :(.

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

Interactive problems, the worst thing that happened to Codeforces.

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

It's better to take a break from prime-factorisation problems this time

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

Good DP in Problem C

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

Yeah binary strings are so fun that I cant stop enjoying them

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

It was cursed for me :(

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

difficult round (•_•)

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

hoping for a color change to cyan :-) Let's see

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

Div.1 + Div.2... Not enjoyed this one tbh...

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

Is there randomized solution of D or something else?

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

Cannot come up with D and I'm about to get negative delta

any idea?

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

i don't know why my D is wrong i am so frustated :( debugged for almost an hour but could not find mistake!!

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

DEFG are too hard. :(

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

Hint for Problem D?

The best I could come up with is the observation that 0 will never give the same GCD against two different values (a property that only 0 has), but I couldn't figure out how to hunt 0 down from there...

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

whenever, there are too many testers saying the round is one the most interesting rounds. Don't take them seriously.

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

Am I really not seeing something, or is C really addition of nC0 + nC1 + ... + nCk, where k is the amount of '0' or '1' depending on the last digit? If that's the case, how can I calculate it in O(n) or O(n log n)?

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

It's too hard. Div.1 + Div.2?

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

The problems are good, but my condition is not good. I have used more than 1 hour thinking about strange algorithms, which lead to insufficient time to finish F.

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

How do you solve D? My idea ( that almost solves it) is to keep track of candidates. Take a random number and check gcd with all the caniddates. The new candidates will be the caniddates with highest gcd because they are the multiples of the inital number (and dont add the inital number to the new candidates), and since zero is a multiple, it will be among the candidates. The number of candidates at worst case decreases by half so the number of queries is n * (1/2 +1/4 +1/8 ...) < 2*n. The only problem is when we happen to start with one. Then we get another n queries and we make 3*n queries.

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

    I found one approach which keeps a track of exactly 3 candidates each time and asks 2 queries to eliminate one; you can use this as a hint or check here.

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

    I did this solution and solved the problem with 1 by first picking two indexes and checking them with every one else (in random order) "in parallel" (i.e. gcd(x, 0), gcd(y, 0), gcd(x, 1), gcd(y, 1), gcd(x, 2), gcd(x, 2)). The moment I get the first non-1 I know that this was not "1" and continue as you described.

    By randomizing index order the expected number to get the first non-1 seems to be "quickly enough", though I'm not sure what are the actual odds (i.e. if we happen to randomly pick x = 1, y = 2 and then the ordering happens to try to check it with 2, 4, 8, 10, ... first it can probably break). But it just passed final tests, so I guess it's fine.

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

DDDDDDDDDDDDDDDDDD!!!!!!!!!!!!!!!!!!!read 1 or -1???!!!!!!!what!?

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

The judges were very kind

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

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

Amazing Contest I really Enjoyed Solving it specially Problem B it is as we called The abstaining plain‏

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

Here's my solution for D

Maintain a list of potential index that could be 0, let's call it v, query v[0] against v[1], v[2], ..., v[v.size() — 1], we can see that if query(v[i]) = max(query(v[1...v.size() — 1])), v[i] can either be 0 or multiple of v[i], remove all v[i] != max(query(v[1...v.size() — 1])), repeat

If there is exactly 1 query(v[i]) = max(query(v[0...v.size() — 1])), let's call that v[i] is vmax, then either v[0] or vmax is 0

Run this until size of v is <= 2, we have our answer! Also, if gcd(v[0], v[1]) = gcd(v[0], v[2]) = 1, v[0] couldn't be 0, so remove it

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

A -> D is pretty easy :D but dunno why my F is RTE >:(.

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

fast coding forces be like

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

Why not prepare this contest as div.1+div.2? I think it is too difficult for div.2. Or maybe arc is anothor good choice, Uh?

Afterall, problems are nice.

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

Wasted a lot of time trying to solve D before even seeing C, but great round with interesting problems nonetheless.

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

this guy https://codeforces.me/profile/jiangly is amazing. Solving problems within 1 minute.

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

A really great round with good problems !

Thanks a lot!

I hope all the upcoming December contests would be like this :)

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

What? A contest without successful hack? Maybe problems are too hard and no one has extra time for hacking?

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

Awesome num theory forces.

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

What was the idea for problem E? Was there a combinatorics formula or some constructive algorithm?

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

    For a fixed tree the weights are also fixed. The proof is to just delete the leaves until the whole tree is deleted. In fact, $$$n$$$ has to be even. Otherwise, the tree is impossible and the answer is $$$0$$$.

    Now we are interested to find $$$\sum d(u,v)$$$ over all ordered pairs $$$(u,v)$$$ ($$$u \neq v$$$) for a fixed tree. After rooting the tree you can get a general formula that depends on subtree size of each node and their parities. The formula is easily extended to hold for all trees of size $$$n$$$. (Of course, the final answer has to be divided by $$$n(n-1)$$$ )

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

The key idea of problem D is to delete non-zero but not to find zero. After I saw the accepted code I got the idea immediately but it is difficult to change the direction while the round is running. I tried to delete 1 all the time on the round and thought about many ways including random, but it seemed impossible to make the probability small enough to pass the problem. Has anyone passed this problem with a random method?

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

    This method works with very high probability :

    Notice that if you query(x, y) for all y with a fixed x, either p(x) = 0 or p(x) = maximum answer to a query. If you let k be the maximum answer to a query, you can notice that you only need to look at multiples of k, and multiples of k are exactly the elements that answered k to the query. Thus, you divided the number of elements by k doing that. This is almost enough to solve the problem, except if the first element you pick is one, and you're gonna use almost 2n queries before dividing for the first time. To avoid that, you can just ask random pairs until you find an element > 2 and start dividing with this element.

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

      Interesting, this is way easier, but I thought using randomness in the beginning wouldn't work, especially with small permutations, so once I realized the problem of picking 1 as your first number I followed the approach of comparing the first and second elements with each of the next elements until I got a gcd different than 1, since both can't be 1. Then you apply the normal strategy with the remaining elements and since you eliminated one number for every two operations I'm pretty sure this should work, although I haven't been able to get AC yet.

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

      How do you check if, in any iteration,p(x)=0?

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

      I tried this approach (just participated virtually now), and it does not work, instead of choosing a random pair I choose a random Y from all multiples of a X, but pretest-5 is evil. :(

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

      I thought about the same method as you described. But in my caculation, valid pairs(gives gcd(a_i,a_j) > 1) only takes about 2/5 in all pairs(C(n,2)) which means we need to do about 20+ times queries to find such a pair with a not-found porbability around 1e-9 and then we need to do at most 2n(n + n/2 + n/4 + ...) times queries in worse case to find the answer. So on the round I thought it is difficult to pass the problem especially for small n like 7 or 8. I cannot give a solid proof of this method but it is true that the real process has a very low probability to enter the worst case(we pick k as 2,4,8,...).

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

I spent about ten minutes to figure out that you should read a 1/-1 after each testcase in problem D.

I bet there's people who spent more TAT.

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

$$$D$$$ looks like author typed something randomly, then suddenly noticed, that this produces "something meaningful", and created problem, which asks to get strictly that "something meaningul".

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

    Well, just to make it clear initial version was to find the whole permutation using atmost $$$3n$$$ queries, which is quite natural and cool imo.

    Testers found it hard and some unintended solution which uses around than $$$3n+\alpha$$$ (where $$$\alpha$$$ varies from $$$30$$$ to $$$40$$$ depending on implementation) were getting cheesed. That is why we decided to have current version. Most of the testers liked it. So we went with current version.

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

My solution to D 185365086 (idea is to take any number and querying it with other valid elements to try to get a higher GCD) shouldn't work but I was able to make it AC through randomization and just running an infinite loop when I am about to exceed total queries so that the system rejudges my submission.

Can anyone try to hack this?

(Edit: Cleaner version 185377734)

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

what's the idea behind B

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

Mathforces!

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

$$$D$$$ was great. Maintain two possibilies, $$$poss[0]$$$ and $$$poss[1]$$$ as the "possible" indexes where $$$0$$$ can be present. Initially $$$poss[0] = 1$$$, $$$poss[1] = 2$$$. Let $$$ g = gcd(p[poss[0]],p[poss[1]]) $$$. (Use the first query to determine $$$g$$$ initially.

Then, start with index $$$3$$$. (And now we need to update $$$poss[0]$$$ and $$$poss[1]$$$).

Calculate $$$gcd(p[poss[0]],p[3])$$$ and $$$gcd(p[poss[1]],p[3])$$$ and $$$gcd(p[poss[0]],p[poss[1]])$$$ (You have already stored it).

Sort them, lets say sorted values are $$$x$$$ $$$y$$$ and $$$z$$$ where $$$x \le y \le z $$$. It can be shown that if $$$gcd(y,z) = x$$$ and $$$x!=z$$$ and $$$y!=z$$$ then, index $$$p$$$ and $$$q$$$ will be the possible candidates for $$$0$$$ where $$$ p $$$ and $$$ q $$$ are the index among ($$$poss[0], poss[1], p[3])$$$ and no index ($$$p$$$ or $$$q$$$) is common in index corresponding to $$$x$$$ and $$$y$$$. (Index corresponding to, say $$$x$$$ means that the two indexes whose gcd is $$$x$$$.). So update $$$poss[0] = p$$$ and $$$poss[1] = q$$$ if the above conditions are satisfied, otherwise don't update it. Then repeat the process for the next index.

At the end, $$$poss[0]$$$ and $$$poss[1]$$$ are the answers. Link for my submission: https://codeforces.me/contest/1762/submission/185373278 (Solved it just after contest :( )

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

I don't understand outputs of interactive problem debuging enviroment

https://codeforces.me/contest/1762/submission/185375790

I manualy checked test1 and test2 and both work hmmm?

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

D has a strong vibe of this problem: https://codeforces.me/contest/1634/problem/D

Not only it asks to find zero, but solutions are very similar too

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

Why gcd(x,0)=x,is it a definition?

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

I am so sad,my rating will drop,because I have never solved interactive problem,so I always got idleness limite exceed in D,but it is a interesting round.

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

for problem B sort the array and make the i+1th index multiples of previous .

Your code here...

	int n = sc.nextInt();
		
		int arr[] = new int[n];
		int cnt = 0;
		for(int i = 0 ; i < n ; i++)
		{
			arr[i] = sc.nextInt();  
		}
		sort(arr);
		
		int ans[][] = new int[n][2];
		for(int i = 0 ; i < n ; i++)
		{
			ans[i][0] = i+1;
			if(i < n-1)
			{
			if(arr[i+1]%arr[i]!=0)
			{
				ans[i+1][1] =arr[i]- (arr[i+1]%arr[i]);
				arr[i+1] +=  arr[i]-(arr[i+1]%arr[i]);
			
			}
			}
		}
		
		System.out.println(n);
		
		for(int i = 0 ; i < n ; i++)
		{
			System.out.println(ans[i][0]+" "+ans[i][1]);
		}
		

why is it failing anybody

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

    After sorted the indexes are rearranged but you should output the original index

    To fix it you should use pair<int,int> {a[i],i} to store the original index, or let b[i]=a[i]*N+i where N>max(n), then sort b, we can get original index=b[i]%N.

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

On E, I got the AC formula

$$$\sum\limits_{m=1}^{n-1}(-1)^m m^{m-1}(n-m)^{n-m-1}\binom{n-2}{m-1}$$$

but couldn't prove it; can anyone provide some reasoning as to why this works?

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

    How did you figure out the formula during the contest?

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

      I got the observation that, if we root the tree at 1, the label of the edge of each node to its ancestor is $$$(-1)^{\text{subtree size}}$$$. Then, I attempted counting based on $$$n$$$'s subtree, but couldn't really manage the path from 1 to $$$n$$$. Trying to sum over all nodes was a tough task too. I just resorted to guessing after a while, and surprisingly a simple tweak to Cayley's Formula works.

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

    Pick any edge in the path $$$1 \rightarrow n$$$. It divides the tree in two subtrees (let's say that the left subtree contains $$$1$$$, and the right subtree contains $$$n$$$). Then, you can iterate over the size $$$m$$$ of the left subtree.

    • The weight of the edge is $$$(-1)^m$$$.
    • You have to choose $$$m-1$$$ nodes between $$$2$$$ and $$$n-1$$$ to put on the left.
    • You have to choose the shape of the two subtrees.
    • You have to choose the endpoints of the edge.
»
4 года назад, скрыть # |
← Rev. 2  
Проголосовать: нравится +1 Проголосовать: не нравится

Missed being candidate master just for 10 points :'( Thanks for problem D, exactly my favourite type of problem.

Upd: Reached candidate master the next contest!

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

4 th test case in c f([1,3])=1 how, extension of 010 can be 00100,01100,00110 hence f([1,3]) should be equal to 3.

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

Ratings updated preliminary, it will be recalculated after removing the cheaters.

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

Am I the only one who understood the problem C incorrectly? At first, I thought each prefix is an independent case and later I thought even after surpassing a prefix the elements constructed could be changed with new incoming characters.

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

Can anyone tell me why am I getting Wrong Answer on testcase 2 for my code of problem A:

include<bits/stdc++.h>

using namespace std;

int main() { int t; cin>>t; while(t--) { long long n,i; cin>>n; long long a[n]; for( i=0;i<n;++i) { cin>>a[i]; } long long EvenCount = 0, OddCount = 0, evenmin=9999999,oddmin=9999999,count=0,sum=0,k; long long Even[n], Odd[n];

for(i = 0; i < n; i ++)
{

if(a[i] % 2 == 0) { Even[EvenCount++] = a[i];

}
else
{
    Odd[OddCount++] = a[i];

}
}
 for(i = 0; i < n; i ++)
{
    sum =sum+a[i];
}

for(i = 0; i < EvenCount; i ++)
{
    if(Even[i]<evenmin)
    {
        evenmin=Even[i];
    }
}
 for(i = 0; i < OddCount; i ++)
{
    if(Odd[i]<oddmin)
    {
        oddmin=Odd[i];
    }
}


if(sum % 2 ==0)
{
    cout<<"0"<<endl;
}

else if(sum % 2 ==1)
{

     if(oddmin < evenmin)
     {


      while(oddmin!=0)
      {
          oddmin=floor(oddmin/2);

          count++;

      }
     cout<<count<<endl;
     }
     else if(oddmin > evenmin)
     {


      while(evenmin!=1)
      {
          evenmin=floor(evenmin/2);

          count++;

      }
     cout<<count<<endl;
     }
}






}


return 0;

}

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

as not a tester, round was great!

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

MikeMirzayanov i had received a mail regarding plag. Both are my accounts, i gave the contest with both of my id's simultaneously.

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

ez div2!