Way to solve Codeforces Round#416 problem E in O(input) steps

Правка en3, от fast_photon, 2024-06-28 15:53:29

I'm sorry about my poor English.

First, make every cross a node. Give each node a position $$$(x, y)$$$. There is an edge between two nodes if and only if:
- $$$|x_1-x_2|+|y_1-y_2|=1$$$ - The edge splits two different characters.

For example, for the example situation in the problem.

We will get the graph:

When calculating the answer of a range $$$[l,r]$$$, it is just like adding edges at the left side of $$$x=l$$$, the right side of $$$x=r$$$, and removing all the edges out of $$$[l,r]$$$. For example, we need to calculate the answer in range $$$[2,4]$$$ in the previous graph. We just need to calculate the number of "faces" in the remaining graph.

Теги 811e, low complexity solution

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en16 Английский fast_photon 2024-06-30 07:03:15 4
en15 Английский fast_photon 2024-06-30 07:02:06 48
en14 Английский fast_photon 2024-06-30 07:00:22 20 #462 -> #416
en13 Английский fast_photon 2024-06-30 06:58:21 4 There's a mistake in spoiler (published)
en12 Английский fast_photon 2024-06-30 06:57:26 0 Tiny change: '811E or #462 E in $\ma' -> '811E or #416 E in $\ma' (saved to drafts)
en11 Английский fast_photon 2024-06-30 06:56:20 0 (published)
en10 Английский fast_photon 2024-06-30 06:50:04 5954
en9 Английский fast_photon 2024-06-30 06:44:28 45
en8 Английский fast_photon 2024-06-30 06:37:26 8
en7 Английский fast_photon 2024-06-30 06:35:40 15
en6 Английский fast_photon 2024-06-30 06:35:15 4
en5 Английский fast_photon 2024-06-30 06:34:44 4 Tiny change: '_1-y_2|=1$\n- The ed' -> '_1-y_2|=1$ \n- The ed'
en4 Английский fast_photon 2024-06-30 06:34:04 14130
en3 Английский fast_photon 2024-06-28 15:53:29 406
en2 Английский fast_photon 2024-06-28 14:59:54 92
en1 Английский fast_photon 2024-06-28 14:49:37 437 Initial revision (saved to drafts)