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

Автор MikeMirzayanov, 4 года назад, По-русски
1259A - С днём рождения, Поликарп!

Автор: MikeMirzayanov

Разбор
1259B - Сделай нечетными

Автор: MikeMirzayanov

Разбор
1259C - Просто как one и two

Автор: MikeMirzayanov

Разбор
1259D - Сыграем в слова?

Автор: MikeMirzayanov

Разбор
1259E - Две ярмарки

Автор: MikeMirzayanov

Разбор
1259F - Красивый прямоугольник

Автор: MikeMirzayanov

Разбор
1259G - Выбывание на дереве

Автор: Endagorion

Разбор
1276E - Четыре камня

Автор: Endagorion

Разбор
1276F - Звёздочки и подстроки

Автор: voidmax

Разбор
  • Проголосовать: нравится
  • +50
  • Проголосовать: не нравится

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

I didn't get it in DIV 1 A it is important to delete the middle letters in the last two paragraphs to avoid appearing a new occurrence after a line is collapsed can anyone provide some testcase

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

My solution to Div.2 E :

1) Perform DFS starting at Vertex a. This DFS function returns when reached at Vertex b.

2) Perform DFS starting at Vertex b. This DFS function returns when reached at Vertex a.

3) When each function saves the visited vertex, there is the vertex that only the first function visited, the vertex that only the second function visited, and the vertex at which both functions visited.

4) Multiply the number of vertices only the first function visited by the number of vertices only the second function visited, and it's the answer.

For example, on this graph, the answer is 5 x 6 = 30.

Code : 67127301

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

    thanks man, easier than the editorial

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

    Do we have to always consider that cities a and b are connected by some road? Can they be diconnected?

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

    Capture9017ce46dd042836.png

    Is the highlighted path valid ? from 2 to A to 1 to B to 3 ?

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

      In your example, the pair (2, 3) will not count towards the solution. The problem states that for a pair (U, V) to count towards the solution, every way to get from city U to city V or from V to U must go through A and B. If there exists a path between them that does NOT go through both A and B, then it does not count towards the solution.

      In your example, there exists a path from 2 to 3 that does NOT go through A and B, thus it does not count towards the solution.

      The only "valid" pairs in your example would be (X1, Y) and (X2, Y). Answer = 2;

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

I really liked this contest, I wish I had participated live.

Here's my solution for Div2-E using BFS. Uses very similar approach to what is mentioned in the editorial. 66995096

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

    I found your solution more intuitive than editorial's solution. Here is DFS based implementation of your idea. 67419480

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

VERY nice editorial MikeMirzayanov

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

    nice handle.

  • »
    »
    12 месяцев назад, # ^ |
    Rev. 3   Проголосовать: нравится 0 Проголосовать: не нравится

    some people learn after doing mistake once, some people will learn after doing the mistake twice, some people learn after doing thrice but every time you commit a mistake map it to the previous occurrence if you remember the previous occurrence, i think that helps you to quickly recognize the mistake. scolding and harassing people or yourself gets you nowhere. you will just end up with anger on yourself and others. once you reach that state there is no going back

    Nobody makes mistakes as if they want to, he/she might have forgotten the mistake itself or they mistake is in disguised form, so he/she was unable to recognize that it was the mistake he/she performed in the past.

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

    just read all the downvote comments and editorial which are intented to help you to think in complicated way and makes you very confusing. Apparently this helps according to stanford research survey

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

Div2 D

5th paragraph, 1st line "In fact, the set of words of kind n10 has no more than n10"

Shouldn't it be "In fact, the set of words of kind n01 has no more than n10"?

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

In the editorial for the problem G:

  • In the recursive equation for dp[v][0], the first product should be "j = 1 to i — 1", not "j = 1 to i = 1".
  • In the recursive equation for dp[v][1], the first product should be "j = 1 to d", not "j = 1 to i = d".
  • In the recursive equation for dp[v][2], the first product should be "j = 1 to i — 1", not "j = 1 to i = 1".
»
4 года назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

In the problem 1277D - Let's Play the Words?, how come the solution to the last sample testcase is given as 1 2

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

can anyone give me a testcase that broke my code?

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

I have a question about div1 E.

How do you perform operations to make $$$\Delta$$$ decrease to $$$\frac{3}{4}\Delta$$$ for stones located at 0, 1, 99999, 100000 according to your alogrithm?

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

In the editorial of question D: Let's Play The Words? Why do we need to reverse $$$n_{01} - n_{10} - 1$$$ strings and not $$$(n_{01} - n_{10}) / 2$$$. Also, can anyone give hints on how to prove that the problem is equivalent to "the Euler traversal of a directed graph with 2 nodes"? Thanks!

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

    It's probably a mistake.

    In the code below you have this: int ans = max(0, (int(max(s01.size(), s10.size())) - int(min(s01.size(), s10.size()))) / 2);

    That is equivalent to $$$(n_{01}-n_{10})/2$$$.

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

can anyone help me in problem B I am getting WA on tc 2 https://codeforces.com/contest/1277/submission/81699789 thanks

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

In Two Fairs, I am not able to understand what exactly (alpha u ,beta u) represents.Can someone clarify? Any help will be appreciated thanks :)

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

For those confused with the editorial for div2 E, I think there is a much easier approach with a similar idea.

  1. build an adjacency list that removes the vertex A from the graph(i.e., don't include edges to/from A) and then calculate the number of vertices connected to B(by performing dfs, starting from B). Let the number be x.

  2. similarly, build an adj list without B and count the number of vertices connected to A. Let the number be y.

  3. Now, the answer is simply (n-x-1)*(n-y-1). This is because (n-x-1) is the number of vertices that cant reach B if A is not present(we subtracted 1 to exclude A). This means that to connect these vertices to B, a path should exist only via A.

A similar conclusion can be made for the (n-y-1) vertices. Thus answer will be (n-x-1)*(n-y-1).

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

For those confused with the editorial for div2 E, I think there is a much easier approach with a similar idea.

  1. build an adjacency list that removes the vertex A from the graph(i.e., don't include edges to/from A) and then calculate the number of vertices connected to B(by performing dfs, starting from B). Let the number be x.

  2. similarly, build an adj list without B and count the number of vertices connected to A. Let the number be y.

  3. Now, the answer is simply (n-x-1)*(n-y-1). This is because (n-x-1) is the number of vertices that cant reach B if A is not present(we subtracted 1 to exclude A). This means that to connect these vertices to B, a path should exist only via A.

A similar conclusion can be made for the (n-y-1) vertices. Thus answer will be (n-x-1)*(n-y-1).

Here is my submission.

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

    Why is the answer of sample test 1(test case 2) is 0 what about the path 1->2->3->4

    upd: My bad understood now

»
12 месяцев назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

Sorry for my dumb question can anyone care to answer this ?

Formally, you need to find the number of pairs of cities x,y such that any path from x to y goes through a and b (in any order). Does this statement mean we need to find x,y such that atleast one path from x to y goes through a and b or is it that every path from x to y goes through a and b ?