Codeforces Round #743 (Div.2) B — Swaps

Revision en6, by WaterGroup, 2021-09-19 15:11:49

I think this problem is not very hard and it's interesting.

Description:

You are given $$$2$$$ arrays $$$a$$$ and $$$b$$$ and the length of them is $$$n$$$.

  • $$$1$$$, $$$3$$$, $$$5$$$, ......, $$$2 * n - 1$$$ is in $$$a$$$.

  • $$$2$$$, $$$4$$$, $$$6$$$, ......, $$$2 * n$$$ is in $$$b$$$.

$$$\mathrm{Algorithm}\ 1:$$$

we use the array $$$mp_i$$$ is $$$i$$$ the distance to the $$$a_1$$$ or $$$b_1$$$.

We can enumerate the $$$i$$$ and the $$$j$$$, and the answer is $$

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en8 English WaterGroup 2021-09-19 15:21:43 2785
en7 English WaterGroup 2021-09-19 15:16:28 2852
en6 English WaterGroup 2021-09-19 15:11:49 162
en5 English WaterGroup 2021-09-19 15:07:30 14
en4 English WaterGroup 2021-09-19 15:06:15 22
en3 English WaterGroup 2021-09-19 15:05:46 22
en2 English WaterGroup 2021-09-19 15:04:51 79
en1 English WaterGroup 2021-09-19 15:04:16 358 Initial revision (published)