Mindeveloped's blog

By Mindeveloped, history, 2 months ago, In English

We hope that you have enjoyed our problems!

2208A - Bingo Candies

Idea by Mindeveloped, prepared by Mindeveloped

Hint 1
Solution
Code
Rate the problem!

2208B - Cyclists

Idea by Mindeveloped, prepared by Mindeveloped

Solution
Code
Rate the problem!

2208C - Stamina and Tasks

Idea by tybbs, prepared by tybbs

Solution
Code
Rate the problem!

2208D2 - Tree Orientation (Hard Version)

Idea by tybbs, prepared by tybbs

Hint 1
Hint 2
Hint 3
Answer to Hint 3 (Solution for D1)
Hint 4
Answer to Hint 4
Solution
Code
Rate the problem!

2208E - Counting Cute Arrays

Idea by tybbs and Mini_PEKKA, prepared by tybbs

Hint 1
Answer to Hint 1
Hint 2
Answer to Hint 2
Hint 3
Answer to Hint 3
Solution
Code
Rate the problem!
  • Vote: I like it
  • +100
  • Vote: I do not like it

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

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

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

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

»
2 months ago, hide # |
 
Vote: I like it +43 Vote: I do not like it

When you solve problem B:

Heheheha

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

On the Generalization of the Problem

https://mirror.codeforces.com/contest/2208/problem/D2

What if the input comes from any directed graph rather than a directed tree?

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

I slept solving e lmao mid contest also b can also be solved with rmq seg tree

»
2 months ago, hide # |
 
Vote: I like it +11 Vote: I do not like it

I think the formula for f[i] is wrong in the editorial for problem C. Shouldn't it be

f[i] = max(f[i + 1] , f[i + 1] * (1 — p[i] / 100) + c[i]).

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

I was able to simulate problem B in around N*log(N) time complexity by putting the first k elements in a priority queue and the rest of the elements in a queue.

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

can anyone explain to me problem B in an easy way to understand?

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

    It's like clash royale game, u have n cards and initially you have your win condition at index p and u have a segment of k from which any cards can be played (means you can play any card in the segment if the cards come in that segment) and you have energy of m if you play any card then a[i] energy will be used, so your task is to figure out how many times you can play win condition in that given energy

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

      The solution is simple there are 2 cases first is the playing the win condition first time if the p is in k range then we can play win condition as first card and that card moves to the back of the queue and if the win condition is not in k range then we need to play (p-k) cards so we can play the win condition for first time , and then the second case after playing win condition for first time is that after every (n-k) cards you can play win condition again so you need a priority queue to play (n-k) cheap cards to maximize the play of win condition.

      Correct me if my approach is wrong:)

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

    It is the kind of problem that you need to deal with when you are playing a sneaky golem deck.

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

Hey I initially submitted my solution for problem A and it showed pretests passed but later when i viewed it , it showed verdict skipped so then i had to resubmit it (after 20 mins) which resulted in me losing points for this question.

Submission ID:https://mirror.codeforces.com/contest/2208/submission/366640037

What Should I do?

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

wow

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

My thought process during B was:

First, obviously you just gotta treat the array as a queue (except you can choose between the first k elements to pop) and then it's trivial!

Then, I forgot how to treat an array as a queue (using .append() and .pop()/.remove() in python)

Then, I came up with an O(k*n) solution which had one slight problem, if anyone's interested it'll be at the end of the comment

In implementing that overcomplicated solution I learned about .append() and .pop()/.remove()

And in the final 11 minutes I finally realized I could use those commands to trivialize the entire problem :(

The overcomplicated solution: - find k-1 biggest numbers in the deck (other than the target ofc) and remove them from the deck - then, find the cost to get the very first aquisition of the wincon. (sum of all elems between 0 and p not including p) - then, find the cost for each subsequent aquisition of the wincon (sum of entire array) - profit the logic being: in the actual solution you'd choose to take the cheapest card available at all times, meaning, after buying n cards you'd be left with k-1 cards that are the priciest being in your deck, plus one card slot that you repetitively use (ask for clarification if you want) and it doesn't work because

(click for answer)

sorry for rambling

it was a fun contest :)

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

    i'm sorry why are you trying to take the biggest number if it's not obstructing the acquisition of the first winning card (i.e., it's after p), especially if you know the you have enough energy/mana to at least get the first winning card?

    per your description of the "overcomplicated solution", this is following the right logic (imo). but i would include the cost of acquiring the winning card (i.e., include cost @ p) and the cost for each subsequent acquisition would be all the remaining cards (including p).

    you can refer to my submission: 366703802 (ignore all the comments)

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

      That was the problem with my logic, I needed to calculate the cost to get the first wincon separately and only then calculate the cost for each subsequent aquisition of the wincon.

»
2 months ago, hide # |
 
Vote: I like it -11 Vote: I do not like it

Great problem E, loved it.

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

Problem C was interesting to me (since I think problem B is just pure implementation, and I'm not good at it).

My first thought was that we could use DP with a two-dimensional array: dp[i][S * 100] (just scale S by 100 since it's a percentage). But then I realized that it would exceed the memory limit.

So there must be a way to reduce the S dimension. That means it needs to become a constant at some point (sorry for this explanation, it's just how by brain work through this).

Then I realized that the only S that can always be determined is actually the first moment (where the problem states that the initial S = 1).

I came up with the same solution the author stated above.

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

Good Job!

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

The solutions and the problems themselves are kind of unclear.

»
2 months ago, hide # |
 
Vote: I like it +5 Vote: I do not like it

In fact, a $$$O(n^3/w)$$$ solution passed the problem D2 using optimized bitsets by avx2 instructions when I'm testing.

I discussed this with problem setters, and we all agreed that nobody will pass the D2 by this method, so we didn't make changes to prevent optimized bitsets from being accepted.

accepted link

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

    I guess, I got lucky to get it accepted using bitset (not the optimized bitset).

    Accepted Link

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

      u have suspicious comments in code

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

        You have suspicious rating graph. With so less problems, you gained such a high rating.

        Btw, I write comments in my code if I have solved the problem with a nice idea. Or else, if there is a chance that I could make mistakes in implementation, I first try to clarify my thought process by writing comments and then I implement my idea.

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

I am confused. For problem D, since the statement says that the given matrix is obtained from a tree, then why no solution situations still exist.

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

B can be simply brute-force with greedily picking the smallest in the first k elements. I could not do it if n up to 10^5 :(

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

Problem E was amazing but i feel like the editorial could've been a bit more clear about the idea behind it... it took me a while to understand how the dp is actually calculated

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

Holy florr reference in problem B's code xD

»
2 months ago, hide # |
 
Vote: I like it +5 Vote: I do not like it

I think my solution for D2 should get TLE because its time complexity is O(n^3), but it actually passed.Could someone take a look please

366702216

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

In problem C, how does value of S has no impact ?

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

    It does have an impact it's just how you interpret it:

    The editorial just states that the optimal subset that you choose from i+1 to n (having chosen some till i) does not depend on what your S was at index.

    In other words you could have started with S being equal to 2 and the final answer just would have been multiplied by 2.

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

For D2:

Why does it work to draw edge between a node and another node in its subset with largest subset size?

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

    this helps in this way

    since the suppose both u and v belongs to s

    now lets assume that v is reachable from u, since v is reachable from u all nodes reachable from v will be reachable from u , therefore the size of set of reachable nodes will be greater of u than v,

    therefore when allocating edges between nodes in clearing order of the size will ensure that no two cycle is formed ,as orgiral graph was a tree

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

add hint for task B

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

can anyone tell me why does it gets TLE on problem D2 I am pretty sure its O(N*N)

367132158

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

is there video solution for these queestion? i want to learn to implement trees and graphs for d1 and d2

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

I think Problem D2 should include a note stating that the data input for this problem is quite large, so please use a faster input method. I used an unbound cin, which caused me to keep getting Time Limit Exceeded errors, resulting in a very poor problem-solving experience!

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

well done

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

i brute forced B and got AC. wow.

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

I received a plagiarism warning for this round. I want to clarify that both accounts involved belong to me. I used them during the contest, which I now understand is against Codeforces rules.

I sincerely apologize for this mistake. I will use only one account for future contests and will strictly follow all rules.

You can ban the other account, but let me keep this one.

»
4 weeks ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

I think D is a wonderful problem!

»
2 weeks ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Even after struggling with the question B for more than couple of hours, I had to look at the solution....

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

:(