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

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

Good day, Codeforces! Or in my language, magandang araw, Codeforces!

Codeforces Round 597 (Div. 2) will be held on Nov/01/2019 17:35 (Moscow time). Is it rated? Yes, but only for participants below 2100 rating.

Of course, this round is not made by me alone. So, I would like to thank the following people for their help in making this round possible:

There will be 6 problems, and you will be given 2 hours to solve them.

The scoring distribution is as follows: 750-750-1250-1750-2250-2500.

I hope you enjoy the round!

Update: editorial is out now

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

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

best round i ever tested. keima orz

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

Are you the first one from Philippines to make a contest on codeforces ?

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

I hope I can become candidate master after this round :DDDDDDDDD

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

After almost 3 years I am back on CodeForces and gonna participate in this round. Wish me luck!

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

It clashes with a codechef round , but after reading comments from testers ,it seems like, i should ditch that and participate here ...

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

I think it must be one of the best contests in Codeforces!

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

I wish contest has strong pretests. I don't like to take wrong answers on main tests.

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

As a tester, I enjoyed solving problems. Well written problem statements mixed with Chinese culture. One of the problems is about a childhood game and it was completely interesting for me!

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

Keima915 OP, from green to orange in 7 months .. interested about the contest to start my 7 months journey :p

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

hope solve a,b,c

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

Please can anyone say me this round I wanna be specialist how many problems must I solve

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

Expect for the constest!

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

I wish I can get expert in the contest again. :)

Good luck to everyone!

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

I m back Bois.. Had a busy October but now I am back to top the charts again.

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

The contestants had to face some difficulty in the previous contest due to several server failure. Though it was overcome in few seconds but its disappointing to reload the page over and over again during the contest hour. Div-2 rating changes also had to roll back because of some problems and we had to wait for several hours to get the rating changes in the last contest. Hope the authority will take care of these matters in this round.

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

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

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

Best of luck in your first contest!

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

Why first and second question has same score distribution....does that mean they have same difficulty level??

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

Hope we have a fair race :)

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

I hope that I can turn it into a blue name.

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

Another DISGUSTING reading contest.

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

strong pre test cases for problems at code forces I ever seen!!

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

Wrong answer on pretest 13 on problem D, No idea why. :(

Any one have idea what is going on in pretest 13 ?

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

TC 9 of problem C?

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

how to solve D?

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

    Kruskal or Prim to find smallest tree. However the graph must be modified a little bit. Add a new node (let's say it's the power supply for the power stations) and the edge from this source to each of n nodes is equal to the cost to build a station there.

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

      Dont we need to make sure that there is atleast one power station? Wouldnt your approach fail when the power stations cost are really high, but the points are close by?

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

        However, your minimum spanning tree will also need to include the new node, which represents a sort of "super power supply" and ensures that at least one node is connected to the new node, and thus has a power station.

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

        Hmm? a tree is a connected graph, thus the newly added node (power supply) must belong to tree too. If the power supply is connected to node i, then you put a station at node i. Since the supply is always connected to some city because of connectedness, there is always at least one power station.

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

        No because we are finding a spanning tree which is connected if the original graph is connected too thus there'll be a path from the power station to every city.

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

What the hell was pretest 13 in D :(((

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

approach for problem C?

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

what is test case 13 in D

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

I thought this was an amazing round :D What lovely well framed questions

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

Does problem D using Prime Algorithm? I did it but got WA on test case 4. What is TC 4 :(

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

What is pretest 13 of D? Wasted almost half hour :(

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

UwU

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

dpforces

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

How to solve F?

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

I finally realized that it was problem E until I submitted my code(since mirror sites don't show the indices of problems
I fooled myself XDDDDDD

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

Nice round. F is a fairly common problem btw. But it is still nice :)

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

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

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

Nice Contest and problems.

But A was quite similar to this problem.

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

Find out why this gets WA8 (takes less than 5 seconds), i couldn't during the whole contest :DDDDDDDD

Solution

Question #2: which lines cause the trouble?

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

Ques.D) Shichikuji and Power Grid: In this question which concept and data structure are used. I think so Kruskal for the shortest path and DP for choosing the powerhouse or connection.

Suggest or provide some explanation, I am a beginner for this type of question.
  • »
    »
    7 лет назад, скрыть # ^ |
    Rev. 2  
    Проголосовать: нравится +2 Проголосовать: не нравится

    I used priority queue to solve.

    1. First, push the cost of setting plants at each city into priority queue along with city number.

    2. Then, start where cost of setting plant is smallest.

    3. Then push the cost making a connection from this city to every unelectrified city (along with city details) and push them into priority queue. Extract minimum cost (setting plant or making a connection) and go to step 3 (n-1 times).

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

    My solution: Using Kruskal:

    Create all the possible edges and their weights(using formula in the statement). Sort the edges according to their weights.

    Suppose you are trying to connect the connected component U and the connected component V using the edges (x, y). Basically you have 2 options:

    • Build a power station in a city in U and a power station in a city in V (Just pick the city with less cost). You don't have to build the edge (x, y) anymore.

    • If you decide to build the edge (x, y) to connect U and V, then you have to build a power station in a city in the union of U and V. Just pick the smallest one.

    Just pick the optimal options for each edge (x, y) and add up the cost.

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

In A I guessed from test cases that a and b needs to be coprime, and the submission worked, But I don't get why is this correct answer. For example a = 3, b = 7 there are infinitely many numbers which are coprime to 3 as well as 7, then aren't there infinite black numbers?

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

D can be solved using a trick: create a virtual vertex, let's denote it as n + 1, then for every vertex connect it to (n + 1)th vertex with an edge having a weight equal to the vextex's c value. Then the problem becomes finding the MST of a given graph.

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

The competition was awesome !!

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

Maybe I'm the only one who solve B using dp and C using 2-dimension dp (I didn't think of Fibonacci or any stuffs related to it)

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

In problem C, I was using square free Fibonacci series. But, I got WA on pretest 9. Can someone help me?? My solution

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

Anyone notices that there seems to be no one (at least very very few people) that fails system test. Amazing contest!

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

Damn, these 4 ms help me become a candidate master!

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

I converted the problem C into "how many ways you can get a sum s using coins {1,2}"..then somehow didn't able to implement it in time...Its kind of sad

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

Can someone help me with solution of D.. Here's my submission 64039124
My idea was to check if a node can be connected with any other node such that the cost for wiring is minimum and less than or equal to the cost to build a power station on that node. If such a node is available then construct an edge between them. Otherwise build a power station on that node.
Lastly, if a component has no such node which has power station in it , then build a power station that requires minimum cost in one of the node of the component..

It is generating way too much minimum cost for test case 13. I couldnt find why

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

A very balanced contest with strong cases , thank you :)

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

Great round! Thank you)

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

I had following idea to D. Lets make minimum spanning tree of graph with edges $$$c(i, j) = (k_i+k_j) * d(i, j)$$$ for all $$$i , j$$$. Firstly lets add the cheapest plant. Then sort edges in non-increasing order and we will try to delete every edge. If we are considering edge $$$(x,y)$$$ let $$$c_1$$$ will be component with vert $$$x$$$ of tree without edge $$$(x, y)$$$ and $$$c_2$$$ will be component with vert $$$y$$$ of tree without edge $$$(x, y)$$$. Only one of this components has installed plant now. Let it be $$$c_2$$$ . Then find cost of the cheapest plant in $$$c_2$$$ and check if its better to add plant instead of edge from spanning tree. If its better to add plant, we delete edge $$$(x, y)$$$ and add plant.

But, my solution got WA13. I will be grateful if you point out my mistake.

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

    Not entirely sure but could be that you are not using the "cost" of power plant while sorting, you are only using wiring cost while sorting? Both types of costs need to be consider.

    edges.pb(tii((k[i] + k[j]) * dist(i, j, coord), i, j));
    
    SORT(edges);
    
    
»
7 лет назад, скрыть # |
 
Проголосовать: нравится +15 Проголосовать: не нравится

Thanks DeliciousFlatChest !

That was a good contest !

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

However, she died when she was only in fifth grade so she is not smart enough for this.

Wait, what codeforces?

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

Has anyone solved D using dynamic programming?

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

Another solution for D is the O(n^2) version of Prim's algorithm which works better on a dense graph. It doesn't need extra dummy nodes either. Is it the most efficient solution?

I solved D in this way after the round, but my implementation was slower than I expected.

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

Can anyone help me with problem D. I sumbited the same code twice, and in the constest y got TLE, but after resumbitting i got AC. https://codeforces.me/contest/1245/submission/64045463 https://codeforces.me/contest/1245/submission/64035229

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

    Your AC code was just 4 ms away from TLE. It just got lucky. The execution time of the same code can differ by a few ms in different submissions. That is the reason behind TLE. Your code was not just lucky enough to get AC in contest time!

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

D is very much similar to this problem : https://vjudge.net/problem/LightOJ-1059

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

Although the contest was very well written and prepared, but still after seeing the next contest, I am like — "Finally, a div. 3 round...., Yay!"

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

Hello my solution to problem D is either bugged or incorrect. With bugs I can cope but I worry it might be simply incorrect. It fails to pass test 13 (wrong answer).

My idea:

Firstly, take each city and make network out of it, making total n networks. Assume that every network doesn't have electricity supplied to it.

while (there exists network that doesnt have electricity supplied) {
  take any network P that doesnt have electricity supplied

  if (its cheaper to build plant inside P, than to connect P to any other network
      (OR) its impossible to connect P to any other network (there are noo other networks)) {
    build plant (cheapest possible amongst members in P) inside P supplying electricity to it
  }
  else {
    build connection between P andd other, closest possible network (closest = cheapest road)
    merging two networks into one
  }
}

I'm not worried about time complexity as above can be implemented in a fairly fast way. Just whether this should work or not.

Thanks for help in advance.

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

How are you supposed to solve D using Kruskal's Algorithm?

When I sorted the 2,000,000 edges, I got TLE on Test 7. Is this only because I used Java, or is Kruskal too slow in general for this problem?

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

great job I love this round too

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

Can someone help me for problem B? I cannot find out where I am wrong? 64097713

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

    The way you find the optimal sequence of moves(your string 'alice') in the case of YES is wrong.

    Try this case to find what you did wrong.

    test case
    correct answer