Tutorial is loading...

Tutorial is loading...

Tutorial is loading...

Tutorial is loading...

Tutorial is loading...

Tutorial is loading...

# | User | Rating |
---|---|---|

1 | tourist | 3764 |

2 | slime | 3592 |

3 | maroonrk | 3535 |

4 | Benq | 3513 |

5 | jiangly | 3509 |

6 | ecnerwala | 3508 |

7 | MiracleFaFa | 3466 |

8 | ksun48 | 3452 |

9 | Um_nik | 3426 |

10 | greenheadstrange | 3393 |

# | User | Contrib. |
---|---|---|

1 | awoo | 192 |

2 | -is-this-fft- | 191 |

3 | Monogon | 184 |

4 | YouKn0wWho | 182 |

5 | Um_nik | 181 |

6 | antontrygubO_o | 173 |

7 | maroonrk | 168 |

8 | errorgorn | 165 |

9 | kostka | 164 |

9 | SecondThread | 164 |

Tutorial is loading...

Tutorial is loading...

Tutorial is loading...

Tutorial is loading...

Tutorial is loading...

Tutorial is loading...

Tutorial of Codeforces Round #377 (Div. 2)

↑

↓

Codeforces (c) Copyright 2010-2022 Mike Mirzayanov

The only programming contests Web 2.0 platform

Server time: May/28/2022 05:19:37 (h2).

Desktop version, switch to mobile version.

Supported by

User lists

Name |
---|

Auto comment: topic has been translated by danilka.pro (original revision, translated revision, compare)I think I used a simpler method for C, this is the observation:

Let M be the maximum of {b, d, s}; then the other 2 would be in the best case M — 1. So if b is the maximum, then (d >= b — 1 and s >= b — 1) always holds true.

This is the code: http://codeforces.com/contest/732/submission/21550209

"So if b is the maximum, then (d >= b — 1 and s >= b — 1)

alwaysholds true."In case {

b= 6,d= 3,s= 3} your statement is wrong. In that casebis maximum, butd<b- 1 ands<b- 1. Or did I miss something?No, I'm talking about the ideal situation.

Lets say b = 6, d = 3 and s = 3. Then Vasiliy has 6 breakfasts, and the minimum number of dinners and lunches he would have had is either 5 or 6. In no situation can it be lesser. We want to find the minimum, so our answer would be (5 — 3) + (5 — 3). (Where 5 is the minimum d we could have, and 3 is the d given to us in the problem statement)

Yeah, I used the same trick and it is quite easy than the one given in tutorial

For the case when

`b = 2, d = 3, s = 1`

how is the answer`1`

?Aren't the ones in the bracket the missed meals = 2 ? If you could help me out with where I am going wrong here .. Thanks!

EDIT:

Just understood, it could be represented as this too :

Meaning only the one in the bracket is the missed meal.

managed to do a-e but, i need to read tutorials on problem F , im still a bit confused, can someone explain , what is :

thanks for your help :)

just google it

can someone explain last line for f. with example? why orient (v,to) to (to,v)?

Just think about it, if you are pointing from v→to, you are leaving the largest cycle pointing outwards.

ok understood it. That really made the whole question. Thanks bro.

Hi, I'm not understanding why my submission is getting TLE for Div2 F. can anyone please check it? Here's my submission, 21830666 I have implemented it exactly as given in the tutorial.

In Problem B, test-10:

Obviously my answer is better?

"

Write a program that will find the minumum number of additional walks"I am pretty sure it is not obvious that 4 < 3.

Oh no, I am very sorry. I mixed up

`Answer`

and`Output`

.Div2D Exams

Consider the following test case

The following AC submission gives the answer as 9. I would like to know how is the answer 9 correct. Since subject 3 requires 4 days of preparation, which clearly isn't possible, shouldn't the answer be -1 ?

It was mentioned that the test cases are flawed and some wrong solutions managed to get an AC.

Why is complexity for Problem D O(mlogn)? For each guess, we want to take the subject at the latest possible day right? So we will need to perform a linear scan on the exam days so that we can find the latest day for each subject. So that should be O(nlogn) right? Is anyone able to confirm this?

Did you find an answer for this?

can someone provide an explanation on why is the mentioned strategy of orienting edges in problem F optimal? i.e. why does it allow us to traverse from any vertex to any other vertex in an 'edge' connected component?

Test cases for D are very trivial. All of them pass through wrong solution also.

Can anyone provide proof of correctness for problem F ? I am not sure whether the solution in tutorial is correct

StatementThere will be at least 1 vertex which will has degree — $$$1$$$.

ProofLet $$$d_1$$$ be the vertex which has degree — $$$1$$$. In directed graphs, if every vertex has at least degree — $$$2$$$, it means that graph is cyclic. But, in our situation (there is at least $$$1$$$ bridge) it is impossible. So it means that $$$d_1$$$ vertex can only travel in his own component. (for $$$d_1$$$ vertex the answer will be size of his own component). To maximize the minimum, it is optimal to choose the $$$maximalComponent$$$ as our $$$d_1$$$ vertex.

Can someone please explain the editorial of Problem F? I can't get why the answer is the largest component!

For example take the following graph:

We have two bridges (6,7),(10,11). Now first without considering bridges we will direct other edges,and they will be obviously completely connected as there will be a cycle(because all the bridges already have been removed)

Now come to bridges, if we direct 10--->11 then ri for (i=11,12,13) will be equal to 3 else if we direct 10<---11 then ri for (i=11,12,13) will be equal to 7

So we direct edge from smaller to larger ,to get 7 over 3 Similarly we will do this with 6<---7 else (7--->6) ri for (i=7,8,9,10) will be 4 (focusing on minimum ri)

So largest component can reach only to the vertices which come in its component after removing all bridges.If we take direct edge from higher component to lower component (higher and lower is with respect to number of vertices in component) ,then minimum can't be maximize,therefore answer will be largest component.

Happy Coding :)

That was really a great explanation. Thanks!

In problem B, why the count of the new walk is 2 and not 1?

Problem D please someone Add this Test Case if possible

My Code Output

12

Actual Output

17

Still it got Accepted

I know it's easier to solve problem B with greedy but still out of my enthusiasm, I wish to do it using DP so please can someone suggest any recursive DP expression for this Problem B.Thanks for your valuable time!!

the test cases of problem D are weak.my solution is wrong but got ac. for the test case

16 3

0 0 1 0 2 0 0 3 0 0 0 0 0 0 0 1

2 4 7

ans should be -1 but mine gives 16

Actually we don't need to find bridges in problem F. For every edge $$$(u, v)$$$ in our DFS path, just orient it from $$$v$$$ to $$$u$$$. Refer to my submission: 117700144.

in B why don't we cater for dog's walk if number of days = 1 Example case

Answer according to me

Answer Found

Can someone please explain D

merko bhi batana :joy ans mile to